[Tizen]Update ImfManager and fix Resized&LanguageChanged event
authorminho.sun <minho.sun@samsung.com>
Mon, 14 Aug 2017 08:38:06 +0000 (17:38 +0900)
committerminho.sun <minho.sun@samsung.com>
Mon, 14 Aug 2017 08:39:32 +0000 (17:39 +0900)
This reverts commit eabf781b8758f7d6da4840adfebe53266ea56ff2.

Change-Id: I9a30148b1fc19260ade13d19e28207147ddceceb

NUISamples/NUISamples/NUISamples.TizenTV/examples/text-test2.cs
src/Tizen.NUI/src/public/ImfManager.cs

index 0ba752c..75d43fe 100755 (executable)
-/*\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
+/*
+* Copyright (c) 2017 Samsung Electronics Co., Ltd.
+*
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*
+*/
+
+using System;
+using System.Runtime.InteropServices;
+using Tizen.NUI;
+using Tizen.NUI.UIComponents;
+using Tizen.NUI.BaseComponents;
+using Tizen.NUI.Constants;
+
+namespace TextTest2
+{
+    class Example : NUIApplication
+    {
+        public Example() : base()
+        {
+        }
+
+        public Example(string stylesheet) : base(stylesheet)
+        {
+        }
+
+        public Example(string stylesheet, WindowMode windowMode) : base(stylesheet, windowMode)
+        {
+        }
+
+        protected override void OnCreate()
+        {
+            base.OnCreate();
+            Initialize();
+        }
+
+        private PushButton button;
+        private TextEditor editor;
+        private ImfManager imfManager;
+
+
+        public void Initialize()
+        {
+            Window window = Window.Instance;
+            window.BackgroundColor = Color.White;
+
+            PropertyMap propertyMap = new PropertyMap();
+            propertyMap.Add("placeholderText", new PropertyValue("TextEditor Placeholder Text"));
+            propertyMap.Add("placeholderColor", new PropertyValue(Color.Red));
+            propertyMap.Add("placeholderPointSize", new PropertyValue(12.0f));
+
+            PropertyMap fontStyleMap = new PropertyMap();
+            fontStyleMap.Add("weight", new PropertyValue("bold"));
+            fontStyleMap.Add("width", new PropertyValue("condensed"));
+            fontStyleMap.Add("slant", new PropertyValue("italic"));
+            propertyMap.Add("placeholderFontStyle", new PropertyValue(fontStyleMap));
+
+
+            editor = new TextEditor()
+            {
+                Size2D = new Size2D(500, 300),
+                Position2D = new Position2D(10, 550),
+                BackgroundColor = Color.Magenta,
+                Focusable = true,
+                Placeholder = propertyMap
+            };
+
+            window.Add(editor);
+
+            editor.TextChanged += (obj, e) => {
+                Tizen.Log.Fatal("NUI", "editor line count: " + e.TextEditor.LineCount);
+            };
+
+            editor.ScrollStateChanged += (obj, e) => {
+                Tizen.Log.Fatal("NUI", "editor scroll state:" + e.ScrollState);
+            };
+
+            editor.KeyEvent += OnKeyEvent;
+
+
+            Tizen.Log.Debug("NUI", "editor id: " + editor.ID);
+
+            imfManager = ImfManager.Get();
+            imfManager.AutoEnableInputPanel(false);
+            imfManager.SetInputPanelUserData("layouttype = 1 & entrylimit = 255 & action = clearall_for_voice_commit & caller = org.volt.search - all");
+
+
+            // send privatecommand event
+            ImfManager.ImfEventData imfevent = new ImfManager.ImfEventData(ImfManager.ImfEvent.PrivateCommand, "", 0, 0);
+            imfManager.EventReceived += ImfManager_ImfManagerEventReceived;
+
+            imfManager.LanguageChanged += ImfManager_LanguageChanged;
+
+            imfManager.Activated += (obj, e) => {
+                Tizen.Log.Debug("NUI", "ImfManager Activated !!!!!");
+            };
+            imfManager.StatusChanged += (obj, e) => {
+                Tizen.Log.Debug("NUI", "ImfManager StatusChanged: !!!!!" + e.StatusChanged);
+            };
+            imfManager.Resized += (obj, e) =>
+            {
+                Tizen.Log.Debug("NUI", "ImfManager Resized !!!!!");
+            };
+            imfManager.KeyboardTypeChanged += (obj, e) => {
+                Tizen.Log.Debug("NUI", "ImfManager KeyboardTypeChanged: !!!!!" + e.KeyboardType);
+            };
+
+            button = new PushButton()
+            {
+                LabelText = "Button",
+                Size2D = new Size2D(400, 200),
+                Position2D = new Position2D(10, -10),
+                ParentOrigin = ParentOrigin.BottomLeft,
+                PivotPoint = PivotPoint.BottomLeft,
+                PositionUsesPivotPoint = true,
+                Focusable = true
+            };
+
+            window.Add(button);
+
+            button.UpFocusableView = editor;
+            editor.DownFocusableView = button;
+
+            FocusManager.Instance.SetCurrentFocusView(button);
+        }
+
+        private bool OnKeyEvent(object source, View.KeyEventArgs e)
+        {
+            Tizen.Log.Debug("NUI", "KeyEvent called !!!!!");
+            if (e.Key.State != Key.StateType.Down || editor.Focusable == false)
+            {
+                Tizen.Log.Debug("NUI", "KeyEvent ignored !!!!!");
+                return false;
+            }
+            switch (e.Key.KeyPressedName)
+            {
+                case "Return":
+                    Tizen.Log.Debug("NUI", "KeyPressedName: Return !!!!!");
+                    ShowImf();
+                    return true;
+                case "Select":
+                    Tizen.Log.Debug("NUI", "KeyPressedName: Select !!!!!");
+                    HideImf();
+                    return true;
+                case "Cancel":
+                    Tizen.Log.Debug("NUI", "KeyPressedName: Cancel !!!!!");
+                    HideImf();
+                    return true;
+                case "Down":
+                    Tizen.Log.Debug("NUI", "KeyPressedName: Down !!!!!");
+                    HideImf();
+                    return MoveFocusTo(button);
+            }
+            return false;
+        }
+
+        private void ShowImf()
+        {
+            imfManager.Activate();
+            imfManager.ShowInputPanel();
+            Tizen.Log.Debug("NUI", "IME showed !!!!!");
+        }
+
+        private bool MoveFocusTo(View view)
+        {
+            if (view == null) return false;
+            return FocusManager.Instance.SetCurrentFocusView(view);
+        }
+
+        private void HideImf()
+        {
+            imfManager.Deactivate();
+            imfManager.HideInputPanel();
+            Tizen.Log.Debug("NUI", "IME hided !!!!!");
+        }
+
+        public ImfManager.ImfCallbackData ImfManager_ImfManagerEventReceived(object sender, ImfManager.EventReceivedEventArgs e)
+        {
+            Tizen.Log.Debug("NUI", "ImfManager_ImfManagerEventReceived()!");
+
+            Tizen.Log.Debug("NUI", "e.ImfEventData.PredictiveString= " + e?.ImfEventData?.PredictiveString);
+            Tizen.Log.Debug("NUI", "e.ImfEventData.CursorOffset= " + e?.ImfEventData?.CursorOffset);
+            Tizen.Log.Debug("NUI", "e.ImfEventData.EventName= " + e?.ImfEventData?.EventName);
+            Tizen.Log.Debug("NUI", "e.ImfEventData.NumberOfChars= " + e?.ImfEventData?.NumberOfChars);
+
+            //Be able to compare VD specific private command with ImfEventData.predictiveString
+            if (e.ImfEventData.PredictiveString == "IME_F31")
+            {
+                ImfManager.Get().Deactivate();
+                ImfManager.Get().HideInputPanel();
+                // Do Something the user wants
+                Tizen.Log.Debug("NUI", "ImfManager ImfEventData.PredictiveString: IME_F31!!!");
+            }
+            ImfManager.ImfCallbackData callbackData = new ImfManager.ImfCallbackData(true, 0, e.ImfEventData.PredictiveString, false);
+            Tizen.Log.Debug("NUI", "ImfManager return callbackData!!!");
+            return callbackData;
+        }
+
+        public void ImfManager_LanguageChanged(object sender, EventArgs args)
+        {
+            Tizen.Log.Debug("NUI", "ImfManager LanguageChanged!!!");
+            return;
+        }
+
+        [STAThread]
+        static void _Main(string[] args)
+        {
+            Example example = new Example();
+            example.Run(args);
+        }
+    }
+}
index a7cd1c5..71bbc88 100755 (executable)
@@ -890,13 +890,6 @@ namespace Tizen.NUI
             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
         }
 
             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
         }
 
-        internal static ImfManager GetImfManagerFromPtr(IntPtr cPtr)
-        {
-            ImfManager ret = new ImfManager(cPtr, false);
-            if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
-            return ret;
-        }
-
         /// <summary>
         /// ImfManager activated event arguments.
         /// </summary>
         /// <summary>
         /// ImfManager activated event arguments.
         /// </summary>
@@ -946,7 +939,10 @@ namespace Tizen.NUI
         {
             ImfManagerActivatedEventArgs e = new ImfManagerActivatedEventArgs();
 
         {
             ImfManagerActivatedEventArgs e = new ImfManagerActivatedEventArgs();
 
-            e.ImfManager = ImfManager.GetImfManagerFromPtr(data);
+            if (data != null)
+            {
+                e.ImfManager = Registry.GetManagedBaseHandleFromNativePtr(data) as ImfManager;
+            }
 
             if (_imfManagerActivatedEventHandler != null)
             {
 
             if (_imfManagerActivatedEventHandler != null)
             {
@@ -1001,7 +997,10 @@ namespace Tizen.NUI
         {
             ActivatedEventArgs e = new ActivatedEventArgs();
 
         {
             ActivatedEventArgs e = new ActivatedEventArgs();
 
-            e.ImfManager = ImfManager.GetImfManagerFromPtr(data);
+            if (data != null)
+            {
+                e.ImfManager = Registry.GetManagedBaseHandleFromNativePtr(data) as ImfManager;
+            }
 
             if (_activatedEventHandler != null)
             {
 
             if (_activatedEventHandler != null)
             {
@@ -1068,7 +1067,10 @@ namespace Tizen.NUI
         {
             ImfManagerEventReceivedEventArgs e = new ImfManagerEventReceivedEventArgs();
 
         {
             ImfManagerEventReceivedEventArgs e = new ImfManagerEventReceivedEventArgs();
 
-            e.ImfManager = ImfManager.GetImfManagerFromPtr(data);
+            if (data != null)
+            {
+                e.ImfManager = Registry.GetManagedBaseHandleFromNativePtr(data) as ImfManager;
+            }
 
             if (_imfManagerEventReceivedEventHandler != null)
             {
 
             if (_imfManagerEventReceivedEventHandler != null)
             {
@@ -1130,8 +1132,14 @@ namespace Tizen.NUI
 
             EventReceivedEventArgs e = new EventReceivedEventArgs();
 
 
             EventReceivedEventArgs e = new EventReceivedEventArgs();
 
-            e.ImfManager = ImfManager.GetImfManagerFromPtr(imfManager);
-            e.ImfEventData = ImfEventData.GetImfEventDataFromPtr(imfEventData);
+            if (imfManager != null)
+            {
+                e.ImfManager = Registry.GetManagedBaseHandleFromNativePtr(imfManager) as ImfManager;
+            }
+            if (imfEventData != null)
+            {
+                e.ImfEventData = ImfEventData.GetImfEventDataFromPtr(imfEventData);
+            }
 
             if (_eventReceivedEventHandler != null)
             {
 
             if (_eventReceivedEventHandler != null)
             {
@@ -1206,7 +1214,10 @@ namespace Tizen.NUI
         {
             ImfManagerStatusChangedEventArgs e = new ImfManagerStatusChangedEventArgs();
 
         {
             ImfManagerStatusChangedEventArgs e = new ImfManagerStatusChangedEventArgs();
 
-            e.ImfManager = ImfManager.GetImfManagerFromPtr(data);
+            if (data != null)
+            {
+                e.ImfManager = Registry.GetManagedBaseHandleFromNativePtr(data) as ImfManager;
+            }
 
             if (_imfManagerStatusChangedEventHandler != null)
             {
 
             if (_imfManagerStatusChangedEventHandler != null)
             {
@@ -1327,7 +1338,10 @@ namespace Tizen.NUI
         {
             ImfManagerResizedEventArgs e = new ImfManagerResizedEventArgs();
 
         {
             ImfManagerResizedEventArgs e = new ImfManagerResizedEventArgs();
 
-            e.ImfManager = ImfManager.GetImfManagerFromPtr(data);
+            if (data != null)
+            {
+                e.ImfManager = Registry.GetManagedBaseHandleFromNativePtr(data) as ImfManager;
+            }
 
             if (_imfManagerResizedEventHandler != null)
             {
 
             if (_imfManagerResizedEventHandler != null)
             {
@@ -1379,7 +1393,7 @@ namespace Tizen.NUI
         [Obsolete("Please do not use! this will be internal")]
         public ImfVoidSignalType ResizedSignal()
         {
         [Obsolete("Please do not use! this will be internal")]
         public ImfVoidSignalType ResizedSignal()
         {
-            ImfVoidSignalType ret = new ImfVoidSignalType(NDalicManualPINVOKE.ImfManager_ResizedSignal(swigCPtr), true);
+            ImfVoidSignalType ret = new ImfVoidSignalType(NDalicManualPINVOKE.ImfManager_ResizedSignal(swigCPtr), false);
             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
             return ret;
         }
             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
             return ret;
         }
@@ -1432,7 +1446,10 @@ namespace Tizen.NUI
         {
             ImfManagerLanguageChangedEventArgs e = new ImfManagerLanguageChangedEventArgs();
 
         {
             ImfManagerLanguageChangedEventArgs e = new ImfManagerLanguageChangedEventArgs();
 
-            e.ImfManager = ImfManager.GetImfManagerFromPtr(data);
+            if (data != null)
+            {
+                e.ImfManager = Registry.GetManagedBaseHandleFromNativePtr(data) as ImfManager;
+            }
 
             if (_imfManagerLanguageChangedEventHandler != null)
             {
 
             if (_imfManagerLanguageChangedEventHandler != null)
             {
@@ -1484,7 +1501,7 @@ namespace Tizen.NUI
         [Obsolete("Please do not use! this will be internal")]
         public ImfVoidSignalType LanguageChangedSignal()
         {
         [Obsolete("Please do not use! this will be internal")]
         public ImfVoidSignalType LanguageChangedSignal()
         {
-            ImfVoidSignalType ret = new ImfVoidSignalType(NDalicManualPINVOKE.ImfManager_LanguageChangedSignal(swigCPtr), true);
+            ImfVoidSignalType ret = new ImfVoidSignalType(NDalicManualPINVOKE.ImfManager_LanguageChangedSignal(swigCPtr), false);
             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
             return ret;
         }
             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
             return ret;
         }