[Tizen] Fix imfmanager issue and add an imfmanager sample 26/141726/1
authorminho.sun <minho.sun@samsung.com>
Tue, 1 Aug 2017 01:40:41 +0000 (10:40 +0900)
committerminho.sun <minho.sun@samsung.com>
Tue, 1 Aug 2017 01:40:42 +0000 (10:40 +0900)
This reverts commit 31fe7abc308b1cc804e11527b31e411eddc79dc6.

Change-Id: I0684d683dbc704360927f8a4330a751472eba6f6

NUISamples/NUISamples/NUISamples.TizenTV/examples/text-test2.cs [new file with mode: 0755]
Tizen.NUI/src/public/ImfManager.cs

diff --git a/NUISamples/NUISamples/NUISamples.TizenTV/examples/text-test2.cs b/NUISamples/NUISamples/NUISamples.TizenTV/examples/text-test2.cs
new file mode 100755 (executable)
index 0000000..0ba752c
--- /dev/null
@@ -0,0 +1,172 @@
+/*\r
+* Copyright (c) 2017 Samsung Electronics Co., Ltd.\r
+*\r
+* Licensed under the Apache License, Version 2.0 (the "License");\r
+* you may not use this file except in compliance with the License.\r
+* You may obtain a copy of the License at\r
+*\r
+* http://www.apache.org/licenses/LICENSE-2.0\r
+*\r
+* Unless required by applicable law or agreed to in writing, software\r
+* distributed under the License is distributed on an "AS IS" BASIS,\r
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+* See the License for the specific language governing permissions and\r
+* limitations under the License.\r
+*\r
+*/\r
+\r
+using System;\r
+using System.Runtime.InteropServices;\r
+using Tizen.NUI;\r
+using Tizen.NUI.UIComponents;\r
+using Tizen.NUI.BaseComponents;\r
+using Tizen.NUI.Constants;\r
+\r
+namespace TextTest2\r
+{\r
+    class Example : NUIApplication\r
+    {\r
+        public Example() : base()\r
+        {\r
+        }\r
+\r
+        public Example(string stylesheet) : base(stylesheet)\r
+        {\r
+        }\r
+\r
+        public Example(string stylesheet, WindowMode windowMode) : base(stylesheet, windowMode)\r
+        {\r
+        }\r
+\r
+        protected override void OnCreate()\r
+        {\r
+            base.OnCreate();\r
+            Initialize();\r
+        }\r
+\r
+        private PushButton _button;\r
+        private PushButton button2;\r
+        private TextField _field;\r
+        private TextEditor editor;\r
+\r
+\r
+        public void Initialize()\r
+        {\r
+            Window window = Window.Instance;\r
+            window.BackgroundColor = Color.White;\r
+\r
+            _field = new TextField();\r
+            _field.Size2D = new Size2D(500, 300);\r
+            _field.Position2D = new Position2D(530, 550);\r
+            _field.BackgroundColor = Color.Cyan;\r
+            _field.PlaceholderText = "TextField input someth...";\r
+            _field.Focusable = true;\r
+            _field.EnableSelection = true;\r
+            window.Add(_field);\r
+\r
+            PropertyMap propertyMap = new PropertyMap();\r
+            propertyMap.Add("placeholderText", new PropertyValue("TextEditor Placeholder Text"));\r
+            propertyMap.Add("placeholderColor", new PropertyValue(Color.Red));\r
+            propertyMap.Add("placeholderPointSize", new PropertyValue(12.0f));\r
+\r
+            PropertyMap fontStyleMap = new PropertyMap();\r
+            fontStyleMap.Add("weight", new PropertyValue("bold"));\r
+            fontStyleMap.Add("width", new PropertyValue("condensed"));\r
+            fontStyleMap.Add("slant", new PropertyValue("italic"));\r
+            propertyMap.Add("placeholderFontStyle", new PropertyValue(fontStyleMap));\r
+\r
+\r
+            editor = new TextEditor();\r
+            editor.Size2D = new Size2D(500, 300);\r
+            editor.Position2D = new Position2D(10, 550);\r
+            editor.BackgroundColor = Color.Magenta;\r
+            editor.Focusable = true;\r
+            editor.Placeholder = propertyMap;\r
+\r
+            window.Add(editor);\r
+            editor.TextChanged += (obj, e) => {\r
+                Tizen.Log.Fatal("NUI", "editor line count: " + e.TextEditor.LineCount);\r
+            };\r
+\r
+            editor.ScrollStateChanged += (obj, e) => {\r
+                Tizen.Log.Fatal("NUI", "editor scroll state:" + e.ScrollState);\r
+            };\r
+\r
+            Tizen.Log.Debug("NUI", "editor id: " + editor.ID);\r
+\r
+            ImfManager imfManager = ImfManager.Get();\r
+            // send privatecommand event\r
+            ImfManager.ImfEventData imfevent = new ImfManager.ImfEventData(ImfManager.ImfEvent.PrivateCommand, "", 0, 0);\r
+            imfManager.ImfManagerEventReceived += ImfManager_ImfManagerEventReceived;\r
+\r
+            //imfmanager.imfManagerLanguageChanged += ImfManager_LanguageChanged;\r
+\r
+            _button = new PushButton();\r
+            _button.LabelText = "Button1";\r
+            _button.Size2D = new Size2D(400, 200);\r
+            _button.Position2D = new Position2D(10, -10);\r
+            _button.ParentOrigin = ParentOrigin.BottomLeft;\r
+            _button.PivotPoint = PivotPoint.BottomLeft;\r
+            _button.PositionUsesPivotPoint = true;\r
+            _button.Focusable = true;\r
+            window.Add(_button);\r
+\r
+            button2 = new PushButton();\r
+            button2.LabelText = "Button2";\r
+            button2.Size2D = new Size2D(400, 200);\r
+            button2.ParentOrigin = ParentOrigin.BottomLeft;\r
+            button2.PivotPoint = PivotPoint.BottomLeft;\r
+            button2.Position2D = new Position2D(420, -10);\r
+            button2.PositionUsesPivotPoint = true;\r
+            button2.Focusable = true;\r
+            window.Add(button2);\r
+\r
+            _button.UpFocusableView = editor;\r
+            FocusManager.Instance.PreFocusChange += OnPreFocusChange;\r
+        }\r
+\r
+        private View OnPreFocusChange(object source, FocusManager.PreFocusChangeEventArgs e)\r
+        {\r
+            if (!e.ProposedView && !e.CurrentView)\r
+            {\r
+                e.ProposedView = _button;\r
+            }\r
+            return e.ProposedView;\r
+        }\r
+\r
+        public ImfManager.ImfCallbackData ImfManager_ImfManagerEventReceived(object sender, ImfManager.ImfManagerEventReceivedEventArgs e)\r
+        {\r
+            Tizen.Log.Fatal("NUI", "ImfManager_ImfManagerEventReceived()!");\r
+\r
+            Tizen.Log.Fatal("NUI", "e.ImfEventData.PredictiveString= " + e?.ImfEventData?.PredictiveString);\r
+            Tizen.Log.Fatal("NUI", "e.ImfEventData.PredictiveString= " + e?.ImfEventData?.CursorOffset);\r
+            Tizen.Log.Fatal("NUI", "e.ImfEventData.PredictiveString= " + e?.ImfEventData?.EventName);\r
+            Tizen.Log.Fatal("NUI", "e.ImfEventData.PredictiveString= " + e?.ImfEventData?.NumberOfChars);\r
+\r
+            //Be able to compare VD specific private command with ImfEventData.predictiveString\r
+            if (e.ImfEventData.PredictiveString == "IME_F31")\r
+            {\r
+                ImfManager.Get().Deactivate();\r
+                ImfManager.Get().HideInputPanel();\r
+                // Do Something the user wants\r
+                Tizen.Log.Fatal("NUI", "ImfManager ImfEventData.PredictiveString: IME_F31!!!");\r
+            }\r
+            ImfManager.ImfCallbackData callbackData = new ImfManager.ImfCallbackData(true, 0, e.ImfEventData.PredictiveString, false);\r
+            Tizen.Log.Fatal("NUI", "ImfManager return callbackData!!!");\r
+            return callbackData;\r
+        }\r
+\r
+        //public void ImfManager_LanguageChanged(object sender, EventArgs args)\r
+        //{\r
+        //    Tizen.Log.Fatal("NUI", "ImfManager LanguageChanged!!!");\r
+        //    return;\r
+        //}\r
+\r
+        [STAThread]\r
+        static void _Main(string[] args)\r
+        {\r
+            Example example = new Example();\r
+            example.Run(args);\r
+        }\r
+    }\r
+}\r
index 1868cc3..9304124 100755 (executable)
@@ -264,6 +264,11 @@ namespace Tizen.NUI
             private global::System.Runtime.InteropServices.HandleRef swigCPtr;
             protected bool swigCMemOwn;
 
+            internal IntPtr GetImfCallbackDataPtr()
+            {
+                return (IntPtr)swigCPtr;
+            }
+
             internal ImfCallbackData(global::System.IntPtr cPtr, bool cMemoryOwn)
             {
                 swigCMemOwn = cMemoryOwn;
@@ -791,7 +796,7 @@ namespace Tizen.NUI
             }
         }
 
-        private delegate ImfCallbackData ImfManagerEventReceivedEventCallbackType(global::System.IntPtr imfManager, global::System.IntPtr imfEventData);
+        private delegate global::System.IntPtr ImfManagerEventReceivedEventCallbackType(global::System.IntPtr imfManager, global::System.IntPtr imfEventData);
         private ImfManagerEventReceivedEventCallbackType _imfManagerEventReceivedEventCallback;
 
         private event EventHandlerWithReturnType<object, ImfManagerEventReceivedEventArgs, ImfCallbackData> _imfManagerEventReceivedEventHandler;
@@ -821,8 +826,10 @@ namespace Tizen.NUI
             }
         }
 
-        private ImfCallbackData OnImfManagerEventReceived(global::System.IntPtr imfManager, global::System.IntPtr imfEventData)
+        private global::System.IntPtr OnImfManagerEventReceived(global::System.IntPtr imfManager, global::System.IntPtr imfEventData)
         {
+            ImfCallbackData imfCallbackData = null;
+
             ImfManagerEventReceivedEventArgs e = new ImfManagerEventReceivedEventArgs();
 
             e.ImfManager = ImfManager.GetImfManagerFromPtr(imfManager);
@@ -830,9 +837,16 @@ namespace Tizen.NUI
 
             if (_imfManagerEventReceivedEventHandler != null)
             {
-                return _imfManagerEventReceivedEventHandler(this, e);
+                imfCallbackData = _imfManagerEventReceivedEventHandler(this, e);
+            }
+            if (imfCallbackData != null)
+            {
+                return imfCallbackData.GetImfCallbackDataPtr();
+            }
+            else
+            {
+                return new ImfCallbackData().GetImfCallbackDataPtr();
             }
-            return null;
         }
 
         internal ImfEventSignalType EventReceivedSignal()