Răsfoiți Sursa

Added IME support on desktop renaming

TC pushbot 5 4 ani în urmă
părinte
comite
5d1ce47b21

Fișier diff suprimat deoarece este prea mare
+ 7 - 0
web/Cyinput/cyinput.js


BIN
web/Cyinput/img/desktop_icon.png


BIN
web/Cyinput/img/desktop_icon.psd


BIN
web/Cyinput/img/small_icon.png


BIN
web/Cyinput/img/small_icon.psd


+ 30 - 0
web/Cyinput/index.html

@@ -0,0 +1,30 @@
+<!DOCTYPE html>
+<html>
+	<head>
+		<meta charset="UTF-8">
+		<meta name="apple-mobile-web-app-capable" content="yes" />
+		<meta name="viewport" content="user-scalable=no, width=device-width, initial-scale=1, maximum-scale=1"/>
+		<meta name="theme-color" content="#4b75ff">
+		
+
+		<link rel="manifest" crossorigin="use-credentials" href="manifest.json">
+		<title>Cyinput</title>
+		<style>
+			body{
+				background-color: rgba(255,255,255,0.9);
+			}
+		</style>
+	</head>
+	<body>
+		<script src="../script/jquery.min.js"></script>
+		<script src="../script/ao_module.js"></script>
+		<script src="cyinput.js"></script>
+		<script>
+			//Initialize ao_module events
+			ao_module_setFixedWindowSize();
+
+			//Pin the window to top layer
+			ao_module_setTopMost();
+		</script>
+	</body>
+</html>

+ 22 - 0
web/Cyinput/init.agi

@@ -0,0 +1,22 @@
+/*
+	Video Module Register Script
+*/
+
+//Setup the module information
+var moduleLaunchInfo = {
+    Name: "速型輸入法",
+	Desc: "Cyinput 速型輸入法",
+	Group: "IME",
+	IconPath: "Cyinput/img/small_icon.png",
+	Version: "0.1.0",
+	StartDir: "Cyinput/index.html",
+	SupportFW: true,
+	LaunchFWDir: "Cyinput/index.html",
+	SupportEmb: false,
+	InitFWSize: [170, 260],
+	SupportedExt: []
+}
+
+
+//Register the module
+registerModule(JSON.stringify(moduleLaunchInfo));

+ 5 - 0
web/Dummy/index.html

@@ -22,6 +22,11 @@
             <h3>This is a Dummy Testing Module</h3>
             <p>Received drag-in filelist (if any)</p>
             <span id="flist"></span>
+            <div class="ui divider"></div>
+            <p>Try open an IME and type something</p>
+            <input class="ui fluid input" val="Test"></input>
+            <br>
+            <textarea></textarea>
             <br>
             <button class="ui blue button" onClick="pinWindow();">Pin Window</button>
             <button class="ui blue button" onClick="unpinWindow();">Unpin Window</button>

+ 9 - 0
web/Notebook/notebook.html

@@ -28,6 +28,15 @@
                 if (event.which == 83 && event.ctrlKey){
                     event.preventDefault();
                     saveText();
+                }else if (event.target.tagName == "TEXTAREA"){
+                    //Some wierd hack to make SimpleMDE to work with ArozOS IME API
+                    if (parent.window.ime){
+                        parent.window.ime.focus = event.target;
+                        if (parent.window.ime.handler != null){
+                            parent.window.ime.handler(event);
+                        }
+                    }
+                    
                 }
             });
 

+ 40 - 2
web/desktop.system

@@ -908,6 +908,12 @@
         //Context Menu variables
         var menuStartLocation = [0, 0];
 
+        //Input Method Editor objects
+        window.ime = {
+            handler: null,
+            focus: null
+        };
+
         //Others
         var monthNames = ["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"];
         var daysNames = ['Sunday','Monday','Tuesday','Wednesday','Thursday','Friday','Saturday'];
@@ -917,6 +923,7 @@
         var downloadMode = false;
         var isSafari = /^((?!chrome|android).)*safari/i.test(navigator.userAgent);
 
+
         //Initiation functions
         initDesktopTheme();
         initDesktopHostInfo();
@@ -1957,7 +1964,7 @@
             //Move the current fw to top, its z index is now 101
             MoveFloatWindowToTop(object);
             var windowID = $(object).attr("windowId");
-            console.log("Pinning window " + windowID)
+            console.log("[Desktop] Pinning window ID: " + windowID)
             //Move this to fixed layer position
             $(object).addClass("topmost");
             $(object).css("z-index", 501);
@@ -4320,6 +4327,16 @@
             if( index >= 0){
                 $(object).find(".renameInput")[0].setSelectionRange(0, index);
             }
+
+            //Updates 4-5-2021: Added IME support on rename input
+            $(object).find(".renameInput")[0].addEventListener("keydown", function(event){
+                if (window.ime && window.ime.handler != null){
+                    window.ime.handler(event);
+                }else{
+                    //No IME handler. Just continue the input
+                }
+            });
+            window.ime.focus = $(object).find(".renameInput")[0];
         }
 
         function exitRenameMode() {
@@ -4516,7 +4533,11 @@
                         //Set the icon location
                         setIconDesktopLocation(newfn, closestGridIndexLocation[0], closestGridIndexLocation[1], function(){
                             //Refresh the desktop
-                            refresh();
+                            refresh(function(){
+                                var targetNewFile = getObjectFromGridLocation(closestGridIndexLocation[0], closestGridIndexLocation[1]);
+                                console.log("Renaming ", targetNewFile);
+                                enableRenameOnLaunchIconObject(targetNewFile);
+                            });
                         });
                     }
                 }
@@ -4986,6 +5007,23 @@
                 }
             })
         }
+
+        function bindObjectToIMEEvents(object){
+            object.addEventListener("keydown", function(event){
+                if (window.ime && window.ime.handler != null){
+                    window.ime.handler(event);
+                }else{
+                    //No IME handler. Just continue the input
+                }
+            });
+
+            object.addEventListener("focus", function(event){
+                if (window.ime){
+                    //IME exists. Set this field to focused field
+                    window.ime.focus = event.target;
+                }
+            });
+        }
     </script>
 </body>
 

+ 35 - 5
web/script/ao_module.js

@@ -29,11 +29,41 @@ ao_root = ao_module_getAORootFromScriptPath();
     under Web Desktop Mode. 
 */
 
-if (ao_module_virtualDesktop){
-    document.addEventListener("mousedown", function() {
-        //When click on this document, focus this
-        ao_module_focus();
-    }, true);
+document.addEventListener("DOMContentLoaded", function() {
+    if (ao_module_virtualDesktop){
+        //Add window focus handler
+        document.addEventListener("mousedown", function(event) {
+            //When click on this document, focus this
+            ao_module_focus();
+
+            if (event.target.tagName == "INPUT" || event.target.tagName == "TEXTAREA"){
+
+            }else{
+                if (parent.window.ime.focus != null){
+                    parent.window.ime.focus = null;
+                }
+            }
+        }, true);
+    
+        //Add IME registration handler
+        var inputFields = document.querySelectorAll("input,textarea");
+        for (var i = 0; i < inputFields.length; i++){
+            console.log(inputFields[i]);
+            ao_module_bindCustomIMEEvents(inputFields[i]);
+        }
+    }
+});
+
+/*
+    Startup Section Script
+    
+    These functions handle the startup of an ao_module and adapt them into the
+    standard arozos desktop eco-system api
+*/
+
+//Function handle to bind custom IME events
+function ao_module_bindCustomIMEEvents(object){
+    parent.bindObjectToIMEEvents(object);
 }
 
 

Unele fișiere nu au fost afișate deoarece prea multe fișiere au fost modificate în acest diff