From b71aa88ce0e4236a1a2908bfe88b8bd2ffa09631 Mon Sep 17 00:00:00 2001 From: "minho.sun" Date: Tue, 1 Aug 2017 10:40:41 +0900 Subject: [PATCH] [Tizen] Fix imfmanager issue and add an imfmanager sample This reverts commit 31fe7abc308b1cc804e11527b31e411eddc79dc6. Change-Id: I0684d683dbc704360927f8a4330a751472eba6f6 --- .../NUISamples.TizenTV/examples/text-test2.cs | 172 +++++++++++++++++++++ src/Tizen.NUI/src/public/ImfManager.cs | 22 ++- 2 files changed, 190 insertions(+), 4 deletions(-) create mode 100755 NUISamples/NUISamples/NUISamples.TizenTV/examples/text-test2.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 index 0000000..0ba752c --- /dev/null +++ b/NUISamples/NUISamples/NUISamples.TizenTV/examples/text-test2.cs @@ -0,0 +1,172 @@ +/* +* 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 PushButton button2; + private TextField _field; + private TextEditor editor; + + + public void Initialize() + { + Window window = Window.Instance; + window.BackgroundColor = Color.White; + + _field = new TextField(); + _field.Size2D = new Size2D(500, 300); + _field.Position2D = new Position2D(530, 550); + _field.BackgroundColor = Color.Cyan; + _field.PlaceholderText = "TextField input someth..."; + _field.Focusable = true; + _field.EnableSelection = true; + window.Add(_field); + + 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(); + editor.Size2D = new Size2D(500, 300); + editor.Position2D = new Position2D(10, 550); + editor.BackgroundColor = Color.Magenta; + editor.Focusable = true; + editor.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); + }; + + Tizen.Log.Debug("NUI", "editor id: " + editor.ID); + + ImfManager imfManager = ImfManager.Get(); + // send privatecommand event + ImfManager.ImfEventData imfevent = new ImfManager.ImfEventData(ImfManager.ImfEvent.PrivateCommand, "", 0, 0); + imfManager.ImfManagerEventReceived += ImfManager_ImfManagerEventReceived; + + //imfmanager.imfManagerLanguageChanged += ImfManager_LanguageChanged; + + _button = new PushButton(); + _button.LabelText = "Button1"; + _button.Size2D = new Size2D(400, 200); + _button.Position2D = new Position2D(10, -10); + _button.ParentOrigin = ParentOrigin.BottomLeft; + _button.PivotPoint = PivotPoint.BottomLeft; + _button.PositionUsesPivotPoint = true; + _button.Focusable = true; + window.Add(_button); + + button2 = new PushButton(); + button2.LabelText = "Button2"; + button2.Size2D = new Size2D(400, 200); + button2.ParentOrigin = ParentOrigin.BottomLeft; + button2.PivotPoint = PivotPoint.BottomLeft; + button2.Position2D = new Position2D(420, -10); + button2.PositionUsesPivotPoint = true; + button2.Focusable = true; + window.Add(button2); + + _button.UpFocusableView = editor; + FocusManager.Instance.PreFocusChange += OnPreFocusChange; + } + + private View OnPreFocusChange(object source, FocusManager.PreFocusChangeEventArgs e) + { + if (!e.ProposedView && !e.CurrentView) + { + e.ProposedView = _button; + } + return e.ProposedView; + } + + public ImfManager.ImfCallbackData ImfManager_ImfManagerEventReceived(object sender, ImfManager.ImfManagerEventReceivedEventArgs e) + { + Tizen.Log.Fatal("NUI", "ImfManager_ImfManagerEventReceived()!"); + + Tizen.Log.Fatal("NUI", "e.ImfEventData.PredictiveString= " + e?.ImfEventData?.PredictiveString); + Tizen.Log.Fatal("NUI", "e.ImfEventData.PredictiveString= " + e?.ImfEventData?.CursorOffset); + Tizen.Log.Fatal("NUI", "e.ImfEventData.PredictiveString= " + e?.ImfEventData?.EventName); + Tizen.Log.Fatal("NUI", "e.ImfEventData.PredictiveString= " + 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.Fatal("NUI", "ImfManager ImfEventData.PredictiveString: IME_F31!!!"); + } + ImfManager.ImfCallbackData callbackData = new ImfManager.ImfCallbackData(true, 0, e.ImfEventData.PredictiveString, false); + Tizen.Log.Fatal("NUI", "ImfManager return callbackData!!!"); + return callbackData; + } + + //public void ImfManager_LanguageChanged(object sender, EventArgs args) + //{ + // Tizen.Log.Fatal("NUI", "ImfManager LanguageChanged!!!"); + // return; + //} + + [STAThread] + static void _Main(string[] args) + { + Example example = new Example(); + example.Run(args); + } + } +} diff --git a/src/Tizen.NUI/src/public/ImfManager.cs b/src/Tizen.NUI/src/public/ImfManager.cs index 1868cc3..9304124 100755 --- a/src/Tizen.NUI/src/public/ImfManager.cs +++ b/src/Tizen.NUI/src/public/ImfManager.cs @@ -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 _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() -- 2.7.4