2 * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved
\r
4 * Licensed under the Apache License, Version 2.0 (the License);
\r
5 * you may not use this file except in compliance with the License.
\r
6 * You may obtain a copy of the License at
\r
8 * http://www.apache.org/licenses/LICENSE-2.0
\r
10 * Unless required by applicable law or agreed to in writing, software
\r
11 * distributed under the License is distributed on an AS IS BASIS,
\r
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
\r
13 * See the License for the specific language governing permissions and
\r
14 * limitations under the License.
\r
19 using System.Collections.Generic;
\r
20 using System.Runtime.InteropServices;
\r
21 using static Interop.InputMethod;
\r
23 namespace Tizen.Uix.InputMethod
\r
26 /// Enumeration of the key codes.
\r
27 /// If keycode & 0xff000000 == 0x01000000 then this key code is directly encoded 24-bit UCS character.The UCS value is keycode & 0x00ffffff.
\r
28 /// Defines the list of keys supported by the system.Note that certain keys may not be available on all devices.
\r
33 /// The backspace key
\r
35 IME_KEY_BackSpace = 0xFF08,
\r
39 IME_KEY_Tab = 0xFF09,
\r
41 /// The linefeed key
\r
43 IME_KEY_Linefeed = 0xFF0A,
\r
47 IME_KEY_Clear = 0xFF0B,
\r
51 IME_KEY_Return = 0xFF0D,
\r
55 IME_KEY_Pause = 0xFF13,
\r
57 /// The scroll lock key
\r
59 IME_KEY_Scroll_Lock = 0xFF14,
\r
63 IME_KEY_Sys_Req = 0xFF15,
\r
67 IME_KEY_Escape = 0xFF1B,
\r
71 IME_KEY_Delete = 0xFFFF,
\r
73 /* Cursor control & motion */
\r
77 IME_KEY_Home = 0xFF50,
\r
79 /// The left directional key
\r
81 IME_KEY_Left = 0xFF51,
\r
83 /// The up directional key
\r
85 IME_KEY_Up = 0xFF52,
\r
87 /// The right directional key
\r
89 IME_KEY_Right = 0xFF53,
\r
91 /// The down directional key
\r
93 IME_KEY_Down = 0xFF54,
\r
95 /// The prior, previous key
\r
97 IME_KEY_Prior = 0xFF55,
\r
101 IME_KEY_Page_Up = 0xFF55,
\r
105 IME_KEY_Next = 0xFF56,
\r
107 /// The page down key
\r
109 IME_KEY_Page_Down = 0xFF56,
\r
113 IME_KEY_End = 0xFF57,
\r
117 IME_KEY_Begin = 0xFF58,
\r
119 /* Misc Functions */
\r
123 IME_KEY_Select = 0xFF60,
\r
127 IME_KEY_Print = 0xFF61,
\r
129 /// The execute, run, do key
\r
131 IME_KEY_Execute = 0xFF62,
\r
135 IME_KEY_Insert = 0xFF63,
\r
139 IME_KEY_Undo = 0xFF65,
\r
143 IME_KEY_Redo = 0xFF66,
\r
147 IME_KEY_Menu = 0xFF67,
\r
151 IME_KEY_Find = 0xFF68,
\r
153 /// The cancel, stop, abort, exit key
\r
155 IME_KEY_Cancel = 0xFF69,
\r
159 IME_KEY_Help = 0xFF6A,
\r
163 IME_KEY_Break = 0xFF6B,
\r
165 /// The character set switch key
\r
167 IME_KEY_Mode_switch = 0xFF7E,
\r
169 /// The num lock key
\r
171 IME_KEY_Num_Lock = 0xFF7F,
\r
175 /// The Numpad space key
\r
177 IME_KEY_KP_Space = 0xFF80,
\r
179 /// The Numpad tab key
\r
181 IME_KEY_KP_Tab = 0xFF89,
\r
183 /// The Numpad enter key
\r
185 IME_KEY_KP_Enter = 0xFF8D,
\r
187 /// The Numpad function 1 key
\r
189 IME_KEY_KP_F1 = 0xFF91,
\r
191 /// The Numpad function 2 key
\r
193 IME_KEY_KP_F2 = 0xFF92,
\r
195 /// The Numpad function 3 key
\r
197 IME_KEY_KP_F3 = 0xFF93,
\r
199 /// The Numpad function 4 key
\r
201 IME_KEY_KP_F4 = 0xFF94,
\r
203 /// The Numpad home key
\r
205 IME_KEY_KP_Home = 0xFF95,
\r
207 /// The Numpad left key
\r
209 IME_KEY_KP_Left = 0xFF96,
\r
211 /// The Numpad up key
\r
213 IME_KEY_KP_Up = 0xFF97,
\r
215 /// The Numpad right key
\r
217 IME_KEY_KP_Right = 0xFF98,
\r
219 /// The Numpad down key
\r
221 IME_KEY_KP_Down = 0xFF99,
\r
223 /// The Numpad prior, previous key
\r
225 IME_KEY_KP_Prior = 0xFF9A,
\r
227 /// The Numpad page up key
\r
229 IME_KEY_KP_Page_Up = 0xFF9A,
\r
231 /// The Numpad next key
\r
233 IME_KEY_KP_Next = 0xFF9B,
\r
235 /// The Numpad page down key
\r
237 IME_KEY_KP_Page_Down = 0xFF9B,
\r
239 /// The Numpad end key
\r
241 IME_KEY_KP_End = 0xFF9C,
\r
243 /// The Numpad begin key
\r
245 IME_KEY_KP_Begin = 0xFF9D,
\r
247 /// The Numpad insert key
\r
249 IME_KEY_KP_Insert = 0xFF9E,
\r
251 /// The Numpad delete key
\r
253 IME_KEY_KP_Delete = 0xFF9F,
\r
255 /// The Numpad equal key
\r
257 IME_KEY_KP_Equal = 0xFFBD,
\r
259 /// The Numpad multiply key
\r
261 IME_KEY_KP_Multiply = 0xFFAA,
\r
263 /// The Numpad add key
\r
265 IME_KEY_KP_Add = 0xFFAB,
\r
267 /// The Numpad separator key
\r
269 IME_KEY_KP_Separator = 0xFFAC,
\r
271 /// The Numpad subtract key
\r
273 IME_KEY_KP_Subtract = 0xFFAD,
\r
275 /// The Numpad decimal key
\r
277 IME_KEY_KP_Decimal = 0xFFAE,
\r
279 /// The Numpad divide key
\r
281 IME_KEY_KP_Divide = 0xFFAF,
\r
283 /// The Numpad 0 key
\r
285 IME_KEY_KP_0 = 0xFFB0,
\r
287 /// The Numpad 1 key
\r
289 IME_KEY_KP_1 = 0xFFB1,
\r
291 /// The Numpad 2 key
\r
293 IME_KEY_KP_2 = 0xFFB2,
\r
295 /// The Numpad 3 key
\r
297 IME_KEY_KP_3 = 0xFFB3,
\r
299 /// The Numpad 4 key
\r
301 IME_KEY_KP_4 = 0xFFB4,
\r
303 /// The Numpad 5 key
\r
305 IME_KEY_KP_5 = 0xFFB5,
\r
307 /// The Numpad 6 key
\r
309 IME_KEY_KP_6 = 0xFFB6,
\r
311 /// The Numpad 7 key
\r
313 IME_KEY_KP_7 = 0xFFB7,
\r
315 /// The Numpad 8 key
\r
317 IME_KEY_KP_8 = 0xFFB8,
\r
319 /// The Numpad 9 key
\r
321 IME_KEY_KP_9 = 0xFFB9,
\r
323 /* Auxilliary Functions */
\r
325 /// The function 1 key
\r
327 IME_KEY_F1 = 0xFFBE,
\r
329 /// The function 2 key
\r
331 IME_KEY_F2 = 0xFFBF,
\r
333 /// The function 3 key
\r
335 IME_KEY_F3 = 0xFFC0,
\r
337 /// The function 4 key
\r
339 IME_KEY_F4 = 0xFFC1,
\r
341 /// The function 5 key
\r
343 IME_KEY_F5 = 0xFFC2,
\r
345 /// The function 6 key
\r
347 IME_KEY_F6 = 0xFFC3,
\r
349 /// The function 7 key
\r
351 IME_KEY_F7 = 0xFFC4,
\r
353 /// The function 8 key
\r
355 IME_KEY_F8 = 0xFFC5,
\r
357 /// The function 9 key
\r
359 IME_KEY_F9 = 0xFFC6,
\r
361 /// The function 10 key
\r
363 IME_KEY_F10 = 0xFFC7,
\r
365 /// The function 11 key
\r
367 IME_KEY_F11 = 0xFFC8,
\r
369 /// The function 12 key
\r
371 IME_KEY_F12 = 0xFFC9,
\r
373 /// The function 13 key
\r
375 IME_KEY_F13 = 0xFFCA,
\r
377 /// The function 14 key
\r
379 IME_KEY_F14 = 0xFFCB,
\r
381 /// The function 15 key
\r
383 IME_KEY_F15 = 0xFFCC,
\r
385 /// The function 16 key
\r
387 IME_KEY_F16 = 0xFFCD,
\r
389 /// The function 17 key
\r
391 IME_KEY_F17 = 0xFFCE,
\r
393 /// The function 18 key
\r
395 IME_KEY_F18 = 0xFFCF,
\r
397 /// The function 19 key
\r
399 IME_KEY_F19 = 0xFFD0,
\r
401 /// The function 20 key
\r
403 IME_KEY_F20 = 0xFFD1,
\r
405 /// The function 21 key
\r
407 IME_KEY_F21 = 0xFFD2,
\r
409 /// The function 22 key
\r
411 IME_KEY_F22 = 0xFFD3,
\r
413 /// The function 23 key
\r
415 IME_KEY_F23 = 0xFFD4,
\r
417 /// The function 24 key
\r
419 IME_KEY_F24 = 0xFFD5,
\r
421 /// The function 25 key
\r
423 IME_KEY_F25 = 0xFFD6,
\r
425 /// The function 26 key
\r
427 IME_KEY_F26 = 0xFFD7,
\r
429 /// The function 27 key
\r
431 IME_KEY_F27 = 0xFFD8,
\r
433 /// The function 28 key
\r
435 IME_KEY_F28 = 0xFFD9,
\r
437 /// The function 29 key
\r
439 IME_KEY_F29 = 0xFFDA,
\r
441 /// The function 30 key
\r
443 IME_KEY_F30 = 0xFFDB,
\r
445 /// The function 31 key
\r
447 IME_KEY_F31 = 0xFFDC,
\r
449 /// The function 32 key
\r
451 IME_KEY_F32 = 0xFFDD,
\r
453 /// The function 33 key
\r
455 IME_KEY_F33 = 0xFFDE,
\r
457 /// The function 34 key
\r
459 IME_KEY_F34 = 0xFFDF,
\r
461 /// The function 35 key
\r
463 IME_KEY_F35 = 0xFFE0,
\r
465 /* Modifier keys */
\r
467 /// The left shift key
\r
469 IME_KEY_Shift_L = 0xFFE1,
\r
471 /// The right shift key
\r
473 IME_KEY_Shift_R = 0xFFE2,
\r
475 /// The left control key
\r
477 IME_KEY_Control_L = 0xFFE3,
\r
479 /// The right control key
\r
481 IME_KEY_Control_R = 0xFFE4,
\r
483 /// The caps lock key
\r
485 IME_KEY_Caps_Lock = 0xFFE5,
\r
487 /// The shift lock key
\r
489 IME_KEY_Shift_Lock = 0xFFE6,
\r
491 /// The left meta key
\r
493 IME_KEY_Meta_L = 0xFFE7,
\r
495 /// The right meta key
\r
497 IME_KEY_Meta_R = 0xFFE8,
\r
499 /// The left alt key
\r
501 IME_KEY_Alt_L = 0xFFE9,
\r
503 /// The right alt key
\r
505 IME_KEY_Alt_R = 0xFFEA,
\r
507 /// The left super key
\r
509 IME_KEY_Super_L = 0xFFEB,
\r
511 /// The right super key
\r
513 IME_KEY_Super_R = 0xFFEC,
\r
515 /// The left hyper key
\r
517 IME_KEY_Hyper_L = 0xFFED,
\r
519 /// The right hyper key
\r
521 IME_KEY_Hyper_R = 0xFFEE,
\r
527 IME_KEY_space = 0x020,
\r
529 /// The exclamation key
\r
531 IME_KEY_exclam = 0x021,
\r
533 /// The quotedbl key
\r
535 IME_KEY_quotedbl = 0x022,
\r
537 /// The number sign key
\r
539 IME_KEY_numbersign = 0x023,
\r
543 IME_KEY_dollar = 0x024,
\r
545 /// The percent key
\r
547 IME_KEY_percent = 0x025,
\r
549 /// The ampersand key
\r
551 IME_KEY_ampersand = 0x026,
\r
553 /// The apostrophe key
\r
555 IME_KEY_apostrophe = 0x027,
\r
557 /// The parenleft key
\r
559 IME_KEY_parenleft = 0x028,
\r
561 /// The parenright key
\r
563 IME_KEY_parenright = 0x029,
\r
565 /// The asterisk key
\r
567 IME_KEY_asterisk = 0x02a,
\r
571 IME_KEY_plus = 0x02b,
\r
575 IME_KEY_comma = 0x02c,
\r
579 IME_KEY_minus = 0x02d,
\r
583 IME_KEY_period = 0x02e,
\r
587 IME_KEY_slash = 0x02f,
\r
631 IME_KEY_colon = 0x03a,
\r
633 /// The semicolon key
\r
635 IME_KEY_semicolon = 0x03b,
\r
639 IME_KEY_less = 0x03c,
\r
643 IME_KEY_equal = 0x03d,
\r
645 /// The greater key
\r
647 IME_KEY_greater = 0x03e,
\r
649 /// The question key
\r
651 IME_KEY_question = 0x03f,
\r
655 IME_KEY_at = 0x040,
\r
761 /// The left bracket key
\r
763 IME_KEY_bracketleft = 0x05b,
\r
765 /// The backslash key
\r
767 IME_KEY_backslash = 0x05c,
\r
769 /// The right bracket key
\r
771 IME_KEY_bracketright = 0x05d,
\r
773 /// The circumflex key
\r
775 IME_KEY_asciicircum = 0x05e,
\r
777 /// The underscore key
\r
779 IME_KEY_underscore = 0x05f,
\r
783 IME_KEY_grave = 0x060,
\r
889 /// The left brace key
\r
891 IME_KEY_braceleft = 0x07b,
\r
895 IME_KEY_bar = 0x07c,
\r
897 /// The right brace key
\r
899 IME_KEY_braceright = 0x07d,
\r
903 IME_KEY_asciitilde = 0x07e,
\r
907 /// Enumeration of the key masks.
\r
908 /// The key masks indicate which modifier keys is pressed down during the keyboard hit.The special IME_KEY_MASK_RELEASED indicates the key release event.
\r
910 public enum KeyMask
\r
913 /// Key press event without modifier key
\r
915 IME_KEY_MASK_PRESSED = 0,
\r
917 /// The Shift key is pressed down
\r
919 IME_KEY_MASK_SHIFT = (1 << 0),
\r
921 /// The CapsLock key is pressed down
\r
923 IME_KEY_MASK_CAPSLOCK = (1 << 1),
\r
925 /// The Control key is pressed down
\r
927 IME_KEY_MASK_CONTROL = (1 << 2),
\r
929 /// The Alt key is pressed down
\r
931 IME_KEY_MASK_ALT = (1 << 3),
\r
933 /// The Meta key is pressed down
\r
935 IME_KEY_MASK_META = (1 << 4),
\r
937 /// The Win (between Control and Alt) is pressed down
\r
939 IME_KEY_MASK_WIN = (1 << 5),
\r
941 /// The Hyper key is pressed down
\r
943 IME_KEY_MASK_HYPER = (1 << 6),
\r
945 /// The NumLock key is pressed down
\r
947 IME_KEY_MASK_NUMLOCK = (1 << 7),
\r
949 /// Key release event
\r
951 IME_KEY_MASK_RELEASED = (1 << 15),
\r
955 /// This class contains api's related to IME(Input method editor)
\r
957 public static class InputMethodEditor
\r
959 private static Object thisLock = new Object();
\r
960 private static ImeCallbackStructGCHandle _imeCallbackStructGCHandle = new ImeCallbackStructGCHandle();
\r
961 private static event EventHandler<FocusInEventArgs> _focusIn;
\r
962 private static ImeFocusInCb _imeFocusInDelegate;
\r
963 private static event EventHandler<FocusOutEventArgs> _focusOut;
\r
964 private static ImeFocusOutCb _imeFocusOutDelegate;
\r
965 private static event EventHandler<SurroundingTextUpdatedEventArgs> _surroundingTextUpdated;
\r
966 private static ImeSurroundingTextUpdatedCb _imeSurroundingTextUpdatedDelegate;
\r
967 private static event EventHandler<System.EventArgs> _inputContextReset;
\r
968 private static ImeInputContextResetCb _imeInputContextResetDelegate;
\r
969 private static event EventHandler<CursorPositionUpdatedEventArgs> _cursorPositionUpdated;
\r
970 private static ImeCursorPositionUpdatedCb _imeCursorPositionUpdatedDelegate;
\r
971 private static event EventHandler<LangaugeSetEventArgs> _langaugeSet;
\r
972 private static ImeLanguageSetCb _imeLangaugeSetDelegate;
\r
973 private static event EventHandler<ImDataSetEventArgs> _imDataSet;
\r
974 private static ImeImdataSetCb _imeImDataSetDelegate;
\r
975 private static event EventHandler<LayoutSetEventArgs> _layoutSet;
\r
976 private static ImeLayoutSetCb _imeLayoutSetDelegate;
\r
977 private static event EventHandler<ReturnKeyTypeSetEventArgs> _returnKeyTypeSet;
\r
978 private static ImeReturnKeyTypeSetCb _imeReturnKeyTypeSetDelegate;
\r
979 private static event EventHandler<ReturnKeyStateSetEventArgs> _returnKeyStateSet;
\r
980 private static ImeReturnKeyStateSetCb _imeReturnKeyStateSetDelegate;
\r
981 private static event ProcessKeyEventHandler _processKey;
\r
982 private static ImeProcessKeyEventCb _imeProcessKeyDelegate;
\r
983 private static event EventHandler<DisplayLanaguageChangedEventArgs> _displayLanaguageChanged;
\r
984 private static ImeDisplayLanguageChangedCb _imeDisplayLanaguageChangedDelegate;
\r
985 private static event EventHandler<RotationDegreeChangedEventArgs> _rotationDegreeChanged;
\r
986 private static ImeRotationDegreeChangedCb _imeRotationDegreeChangedDelegate;
\r
987 private static event EventHandler<AccessibilityStateChangedEventArgs> _accessibilityStateChanged;
\r
988 private static ImeAccessibilityStateChangedCb _imeAccessibilityStateChangedDelegate;
\r
989 private static event EventHandler<OptionWindowCreatedEventArgs> _optionWindowCreated;
\r
990 private static ImeOptionWindowCreatedCb _imeOptionWindowCreatedDelegate;
\r
991 private static event EventHandler<OptionWindowDestroyedEventArgs> _optionWindowDestroyed;
\r
992 private static ImeOptionWindowDestroyedCb _imeOptionWindowDestroyedDelegate;
\r
993 private static ImeLanguageRequestedCb _imeLanguageRequestedDelegate;
\r
994 private static OutAction<string> _languageRequestedDelegate;
\r
995 private static ImeImdataRequestedCb _imeImDataRequestedDelegate;
\r
996 private static OutAction<byte, uint> _imDataRequestedDelegate;
\r
997 private static ImeGeometryRequestedCb _imeGeometryRequestedDelegate;
\r
998 private static OutAction1<int> _geometryRequestedDelegate;
\r
999 private static Action _userCreate;
\r
1000 private static Action _userTerminate;
\r
1001 private static Action<int, InputMethodContext> _userShow;
\r
1002 private static Action<int> _userHide;
\r
1003 private static ImeCreateCb _create = (IntPtr userData) =>
\r
1005 Log.Info(LogTag, "In Create Delegate");
\r
1006 _userCreate?.Invoke();
\r
1008 private static ImeTerminateCb _terminate = (IntPtr userData) =>
\r
1010 Log.Info(LogTag, "In terminate Delegate");
\r
1011 _userTerminate?.Invoke();
\r
1013 private static ImeShowCb _show = (int contextId, IntPtr context, IntPtr userData) =>
\r
1015 Log.Info(LogTag, "In Show Delegate");
\r
1016 _userShow?.Invoke(contextId, new InputMethodContext(context));
\r
1018 private static ImeHideCb _hide = (int contextId, IntPtr userData) =>
\r
1020 Log.Info(LogTag, "In Hide Delegate");
\r
1021 _userHide?.Invoke(contextId);
\r
1026 /// An Action with 1 out parameter
\r
1028 /// <typeparam name="T">Generic Type</typeparam>
\r
1029 /// <param name="a">The out parameter</param>
\r
1030 public delegate void OutAction<T>(out T a);
\r
1033 /// An Action with 2 out parameter's
\r
1035 /// <typeparam name="T">Generic Type</typeparam>
\r
1036 /// <typeparam name="T1">Generic Type</typeparam>
\r
1037 /// <param name="a">The out parameter 1</param>
\r
1038 /// <param name="b">The out parameter 2</param>
\r
1039 public delegate void OutAction<T,T1>(out T[] a, out T1 b);
\r
1042 /// An Action with 4 out parameter's
\r
1044 /// <typeparam name="T">Generic Type</typeparam>
\r
1045 /// <param name="a">The out parameter 1</param>
\r
1046 /// <param name="b">The out parameter 2</param>
\r
1047 /// <param name="c">The out parameter 3</param>
\r
1048 /// <param name="d">The out parameter 4</param>
\r
1049 public delegate void OutAction1<T>(out T a, out T b, out T c, out T d);
\r
1053 /// Called when an associated text input UI control has focus.
\r
1055 public static event EventHandler<FocusInEventArgs> FocusIn
\r
1061 _imeFocusInDelegate = (int contextId, IntPtr userData) =>
\r
1063 FocusInEventArgs args = new FocusInEventArgs(contextId);
\r
1064 _focusIn?.Invoke(null, args);
\r
1066 ErrorCode error = ImeEventSetFocusInCb(_imeFocusInDelegate, IntPtr.Zero);
\r
1067 if (error != ErrorCode.None)
\r
1069 Log.Error(LogTag, "Add FocusIn Failed with error " + error);
\r
1073 _focusIn += value;
\r
1081 _focusIn -= value;
\r
1087 /// Called when an associated text input UI control loses focus.
\r
1089 public static event EventHandler<FocusOutEventArgs> FocusOut
\r
1095 _imeFocusOutDelegate = (int contextId, IntPtr userData) =>
\r
1097 FocusOutEventArgs args = new FocusOutEventArgs(contextId);
\r
1098 _focusOut?.Invoke(null, args);
\r
1100 ErrorCode error = ImeEventSetFocusOutCb(_imeFocusOutDelegate, IntPtr.Zero);
\r
1101 if (error != ErrorCode.None)
\r
1103 Log.Error(LogTag, "Add FocusOut Failed with error " + error);
\r
1107 _focusOut += value;
\r
1115 _focusOut -= value;
\r
1121 /// Called when an associated text input UI control responds to a request with the surrounding text.
\r
1123 public static event EventHandler<SurroundingTextUpdatedEventArgs> SurroundingTextUpdated
\r
1129 _imeSurroundingTextUpdatedDelegate = (int contextId, IntPtr text, int cursorPos, IntPtr userData) =>
\r
1131 SurroundingTextUpdatedEventArgs args = new SurroundingTextUpdatedEventArgs(contextId, Marshal.PtrToStringAnsi(text), cursorPos);
\r
1132 _surroundingTextUpdated?.Invoke(null, args);
\r
1134 ErrorCode error = ImeEventSetSurroundingTextUpdatedCb(_imeSurroundingTextUpdatedDelegate, IntPtr.Zero);
\r
1135 if (error != ErrorCode.None)
\r
1137 Log.Error(LogTag, "Add SurroundingTextUpdated Failed with error " + error);
\r
1141 _surroundingTextUpdated += value;
\r
1149 _surroundingTextUpdated -= value;
\r
1155 /// Called to reset the input context of an associated text input UI control.
\r
1157 public static event EventHandler<System.EventArgs> InputContextReset
\r
1163 _imeInputContextResetDelegate = (IntPtr userData) =>
\r
1165 _inputContextReset?.Invoke(null, System.EventArgs.Empty);
\r
1167 ErrorCode error = ImeEventSetInputContextResetCb(_imeInputContextResetDelegate, IntPtr.Zero);
\r
1168 if (error != ErrorCode.None)
\r
1170 Log.Error(LogTag, "Add InputContextReset Failed with error " + error);
\r
1174 _inputContextReset += value;
\r
1182 _inputContextReset -= value;
\r
1188 /// Called when the position of the cursor in an associated text input UI control changes.
\r
1190 public static event EventHandler<CursorPositionUpdatedEventArgs> CursorPositionUpdated
\r
1196 _imeCursorPositionUpdatedDelegate = (int cursorPos, IntPtr userData) =>
\r
1198 CursorPositionUpdatedEventArgs args = new CursorPositionUpdatedEventArgs(cursorPos);
\r
1199 _cursorPositionUpdated?.Invoke(null, args);
\r
1201 ErrorCode error = ImeEventSetCursorPositionUpdatedCb(_imeCursorPositionUpdatedDelegate, IntPtr.Zero);
\r
1202 if (error != ErrorCode.None)
\r
1204 Log.Error(LogTag, "Add CursorPositionUpdated Failed with error " + error);
\r
1208 _cursorPositionUpdated += value;
\r
1216 _cursorPositionUpdated -= value;
\r
1222 /// Called to set the preferred language to the input panel.
\r
1223 /// It will be only called when the client application changes the edit field's language attribute after the input panel is shown.
\r
1225 public static event EventHandler<LangaugeSetEventArgs> LangaugeSet
\r
1231 _imeLangaugeSetDelegate = (EcoreIMFInputPanelLang language, IntPtr userData) =>
\r
1233 LangaugeSetEventArgs args = new LangaugeSetEventArgs(language);
\r
1234 _langaugeSet?.Invoke(null, args);
\r
1236 ErrorCode error = ImeEventSetLanguageSetCb(_imeLangaugeSetDelegate, IntPtr.Zero);
\r
1237 if (error != ErrorCode.None)
\r
1239 Log.Error(LogTag, "Add LangaugeSet Failed with error " + error);
\r
1243 _langaugeSet += value;
\r
1251 _langaugeSet -= value;
\r
1257 /// Called to set the application specific data to deliver to the input panel.
\r
1259 public static event EventHandler<ImDataSetEventArgs> ImDataSet
\r
1265 _imeImDataSetDelegate = (IntPtr data, uint dataLength, IntPtr userData) =>
\r
1267 byte[] destination = new byte[dataLength];
\r
1268 Marshal.Copy(data, destination, 0, (int)dataLength);
\r
1269 ImDataSetEventArgs args = new ImDataSetEventArgs(destination, dataLength);
\r
1270 _imDataSet?.Invoke(null, args);
\r
1272 ErrorCode error = ImeEventSetImdataSetCb(_imeImDataSetDelegate, IntPtr.Zero);
\r
1273 if (error != ErrorCode.None)
\r
1275 Log.Error(LogTag, "Add ImDataSet Failed with error " + error);
\r
1279 _imDataSet += value;
\r
1287 _imDataSet -= value;
\r
1293 /// Called when an associated text input UI control requests the input panel to set its layout.
\r
1294 /// It will be only called when the client application changes the edit field's layout attribute after the input panel is shown.
\r
1296 public static event EventHandler<LayoutSetEventArgs> LayoutSet
\r
1302 _imeLayoutSetDelegate = (EcoreIMFInputPanelLayout layout, IntPtr userData) =>
\r
1304 LayoutSetEventArgs args = new LayoutSetEventArgs(layout);
\r
1305 _layoutSet?.Invoke(null, args);
\r
1307 ErrorCode error = ImeEventSetLayoutSetCb(_imeLayoutSetDelegate, IntPtr.Zero);
\r
1308 if (error != ErrorCode.None)
\r
1310 Log.Error(LogTag, "Add LayoutSet Failed with error " + error);
\r
1314 _layoutSet += value;
\r
1322 _layoutSet -= value;
\r
1328 /// Called when an associated text input UI control requests the input panel to set the Return key label.
\r
1329 /// The input panel can show text or image on the Return button according to the Return key action.
\r
1331 public static event EventHandler<ReturnKeyTypeSetEventArgs> ReturnKeyTypeSet
\r
1337 _imeReturnKeyTypeSetDelegate = (EcoreIMFInputPanelReturnKeyType type, IntPtr userData) =>
\r
1339 ReturnKeyTypeSetEventArgs args = new ReturnKeyTypeSetEventArgs(type);
\r
1340 _returnKeyTypeSet?.Invoke(null, args);
\r
1342 ErrorCode error = ImeEventSetReturnKeyTypeSetCb(_imeReturnKeyTypeSetDelegate, IntPtr.Zero);
\r
1343 if (error != ErrorCode.None)
\r
1345 Log.Error(LogTag, "Add ReturnKeyTypeSet Failed with error " + error);
\r
1349 _returnKeyTypeSet += value;
\r
1357 _returnKeyTypeSet -= value;
\r
1363 /// Called when an associated text input UI control requests the input panel to enable or disable the Return key state.
\r
1365 public static event EventHandler<ReturnKeyStateSetEventArgs> ReturnKeyStateSet
\r
1371 _imeReturnKeyStateSetDelegate = (bool state, IntPtr userData) =>
\r
1373 ReturnKeyStateSetEventArgs args = new ReturnKeyStateSetEventArgs(state);
\r
1374 _returnKeyStateSet?.Invoke(null, args);
\r
1376 ErrorCode error = ImeEventSetReturnKeyStateSetCb(_imeReturnKeyStateSetDelegate, IntPtr.Zero);
\r
1377 if (error != ErrorCode.None)
\r
1379 Log.Error(LogTag, "Add ReturnKeyStateSet Failed with error " + error);
\r
1383 _returnKeyStateSet += value;
\r
1391 _returnKeyStateSet -= value;
\r
1397 /// This Handler is associated with ProcessKey
\r
1399 /// <param name="sender">The object raising the event</param>
\r
1400 /// <param name="e">An object of ProcessKeyEventArgs class</param>
\r
1401 /// <returns>true if the event is processed, otherwise the event is not processed and is forwarded to the client application.</returns>
\r
1402 public delegate bool ProcessKeyEventHandler(object sender, ProcessKeyEventArgs e);
\r
1405 /// Called when the key event is received from the external devices or SendKey function.
\r
1406 /// This Event processes the key event before an associated text input UI control does.
\r
1409 /// If the key event is from the external device, DeviceInfo will have its name, class and subclass information.
\r
1411 public static event ProcessKeyEventHandler ProcessKey
\r
1417 _imeProcessKeyDelegate = (KeyCode keycode, KeyMask keymask, IntPtr devInfo, IntPtr userData) =>
\r
1419 ProcessKeyEventArgs args = new ProcessKeyEventArgs(keycode, keymask, devInfo);
\r
1420 bool res = _processKey.Invoke(null, args);
\r
1423 ErrorCode error = ImeEventSetProcessKeyEventCb(_imeProcessKeyDelegate, IntPtr.Zero);
\r
1424 if (error != ErrorCode.None)
\r
1426 Log.Error(LogTag, "Add ProcessKey Failed with error " + error);
\r
1430 _processKey += value;
\r
1438 _processKey -= value;
\r
1444 /// Called when the system display language is changed.
\r
1446 public static event EventHandler<DisplayLanaguageChangedEventArgs> DisplayLanaguageChanged
\r
1452 _imeDisplayLanaguageChangedDelegate = (IntPtr language, IntPtr userData) =>
\r
1454 DisplayLanaguageChangedEventArgs args = new DisplayLanaguageChangedEventArgs(Marshal.PtrToStringAnsi(language));
\r
1455 _displayLanaguageChanged?.Invoke(null, args);
\r
1457 ErrorCode error = ImeEventSetDisplayLanguageChangedCb(_imeDisplayLanaguageChangedDelegate, IntPtr.Zero);
\r
1458 if (error != ErrorCode.None)
\r
1460 Log.Error(LogTag, "Add DisplayLanaguageChanged Failed with error " + error);
\r
1464 _displayLanaguageChanged += value;
\r
1472 _displayLanaguageChanged -= value;
\r
1478 /// Called when the device is rotated.
\r
1480 public static event EventHandler<RotationDegreeChangedEventArgs> RotationDegreeChanged
\r
1486 _imeRotationDegreeChangedDelegate = (int degree, IntPtr userData) =>
\r
1488 RotationDegreeChangedEventArgs args = new RotationDegreeChangedEventArgs(degree);
\r
1489 _rotationDegreeChanged?.Invoke(null, args);
\r
1491 ErrorCode error = ImeEventSetRotationDegreeChangedCb(_imeRotationDegreeChangedDelegate, IntPtr.Zero);
\r
1492 if (error != ErrorCode.None)
\r
1494 Log.Error(LogTag, "Add RotationDegreeChanged Failed with error " + error);
\r
1498 _rotationDegreeChanged += value;
\r
1506 _rotationDegreeChanged -= value;
\r
1512 /// Called when Accessibility in Settings application is on or off.
\r
1514 public static event EventHandler<AccessibilityStateChangedEventArgs> AccessibilityStateChanged
\r
1520 _imeAccessibilityStateChangedDelegate = (bool state, IntPtr userData) =>
\r
1522 AccessibilityStateChangedEventArgs args = new AccessibilityStateChangedEventArgs(state);
\r
1523 _accessibilityStateChanged?.Invoke(null, args);
\r
1525 ErrorCode error = ImeEventSetAccessibilityStateChangedCb(_imeAccessibilityStateChangedDelegate, IntPtr.Zero);
\r
1526 if (error != ErrorCode.None)
\r
1528 Log.Error(LogTag, "Add AccessibilityStateChanged Failed with error " + error);
\r
1532 _accessibilityStateChanged += value;
\r
1540 _accessibilityStateChanged -= value;
\r
1546 /// Called to create the option window.
\r
1549 /// if Input panel requests to open the option window, type will be ImeOptionWindowType.Keyboard.
\r
1550 /// And if Settings application requests to open it, type will be ImeOptionWindowType.SettingApplication.
\r
1552 public static event EventHandler<OptionWindowCreatedEventArgs> OptionWindowCreated
\r
1558 _imeOptionWindowCreatedDelegate = (IntPtr window, ImeOptionWindowType type, IntPtr userData) =>
\r
1560 OptionWindowCreatedEventArgs args = new OptionWindowCreatedEventArgs(new EditorWindow(window), type);
\r
1561 _optionWindowCreated?.Invoke(null, args);
\r
1563 ErrorCode error = ImeEventSetOptionWindowCreatedCb(_imeOptionWindowCreatedDelegate, IntPtr.Zero);
\r
1564 if (error != ErrorCode.None)
\r
1566 Log.Error(LogTag, "Add OptionWindowCreated Failed with error " + error);
\r
1570 _optionWindowCreated += value;
\r
1578 _optionWindowCreated -= value;
\r
1584 /// Called to destroy the option window.
\r
1586 public static event EventHandler<OptionWindowDestroyedEventArgs> OptionWindowDestroyed
\r
1592 _imeOptionWindowDestroyedDelegate = (IntPtr window, IntPtr userData) =>
\r
1594 OptionWindowDestroyedEventArgs args = new OptionWindowDestroyedEventArgs(new EditorWindow(window));
\r
1595 _optionWindowDestroyed?.Invoke(null, args);
\r
1597 ErrorCode error = ImeEventSetOptionWindowDestroyedCb(_imeOptionWindowDestroyedDelegate, IntPtr.Zero);
\r
1598 if (error != ErrorCode.None)
\r
1600 Log.Error(LogTag, "Add OptionWindowDestroyed Failed with error " + error);
\r
1604 _optionWindowDestroyed += value;
\r
1612 _optionWindowDestroyed -= value;
\r
1618 /// Sets the languageRequested Action
\r
1620 /// <param name="languageRequested">
\r
1621 /// Called when an associated text input UI control requests the language from the input panel, requesting for language code.
\r
1623 public static void SetLanguageRequested(OutAction<string> languageRequested)
\r
1625 _imeLanguageRequestedDelegate = (IntPtr userData, out IntPtr langCode) =>
\r
1628 _languageRequestedDelegate(out langauage);
\r
1629 char[] languageArray = langauage.ToCharArray();
\r
1630 langCode = new IntPtr();
\r
1631 Marshal.Copy(languageArray, 0, langCode, languageArray.Length);
\r
1633 ErrorCode error = ImeEventSetLanguageRequestedCb(_imeLanguageRequestedDelegate, IntPtr.Zero);
\r
1634 if (error != ErrorCode.None)
\r
1636 Log.Error(LogTag, "Add SetLanguageRequested Failed with error " + error);
\r
1638 _languageRequestedDelegate = languageRequested;
\r
1642 /// Sets the imDataRequested Action
\r
1644 /// <param name="imDataRequested">
\r
1645 /// Called when an associated text input UI control requests the application specific data from the input panel, requesting for data array and it's length.
\r
1647 public static void SetImDataRequested(OutAction<byte, uint> imDataRequested)
\r
1649 _imeImDataRequestedDelegate = (IntPtr userData, out IntPtr data, out uint dataLength) =>
\r
1653 _imDataRequestedDelegate(out dataArr, out lenghtArr);
\r
1654 data = new IntPtr();
\r
1655 Marshal.Copy(dataArr, 0, data, (int)lenghtArr);
\r
1656 dataLength = lenghtArr;
\r
1658 ErrorCode error = ImeEventSetImdataRequestedCb(_imeImDataRequestedDelegate, IntPtr.Zero);
\r
1659 if (error != ErrorCode.None)
\r
1661 Log.Error(LogTag, "Add SetImDataRequested Failed with error " + error);
\r
1663 _imDataRequestedDelegate = imDataRequested;
\r
1667 /// Sets the GeometryRequested Action
\r
1669 /// <param name="GeometryRequested">
\r
1670 /// Called when an associated text input UI control requests the position and size from the input panel, requesting for x,y,w,h values.
\r
1672 public static void SetGeometryRequested(OutAction1<int> GeometryRequested)
\r
1674 _imeGeometryRequestedDelegate = (IntPtr userData, out int x, out int y, out int w, out int h) =>
\r
1676 int x1, y1, w1, h1;
\r
1677 _geometryRequestedDelegate(out x1, out y1, out w1, out h1);
\r
1683 ErrorCode error = ImeEventSetGeometryRequestedCb(_imeGeometryRequestedDelegate, IntPtr.Zero);
\r
1684 if (error != ErrorCode.None)
\r
1686 Log.Error(LogTag, "Add SetGeometryRequested Failed with error " + error);
\r
1688 _geometryRequestedDelegate = GeometryRequested;
\r
1692 /// Runs the main loop of IME application.
\r
1693 /// This function starts to run IME application's main loop.
\r
1696 /// http://tizen.org/privilege/ime
\r
1698 /// <param name="create">This is called to initialize IME application before the main loop starts up</param>
\r
1699 /// <param name="terminate">This is called when IME application is terminated</param>
\r
1700 /// <param name="show">This is called when IME application is shown</param>
\r
1701 /// <param name="hide">This is called when IME application is hidden</param>
\r
1702 /// <exception cref="InvalidOperationException">
\r
1703 /// This can occur due to the following reasons:
\r
1704 /// 1) The application does not have the privilege to call this function
\r
1705 /// 2) Operation failed
\r
1707 public static void Run(Action create, Action terminate, Action<int, InputMethodContext> show, Action<int> hide)
\r
1709 _userCreate = create;
\r
1710 _userTerminate = terminate;
\r
1714 ImeCallbackStruct _imeCallbackStruct = _imeCallbackStructGCHandle._imeCallbackStruct;
\r
1715 _imeCallbackStruct.create = _create;
\r
1716 _imeCallbackStruct.terminate = _terminate;
\r
1717 _imeCallbackStruct.hide = _hide;
\r
1718 _imeCallbackStruct.show = _show;
\r
1720 ErrorCode error = ImeRun(GCHandle.ToIntPtr(_imeCallbackStructGCHandle._imeCallbackStructHandle), IntPtr.Zero);
\r
1721 if (error != ErrorCode.None)
\r
1723 Log.Error(LogTag, "Run Failed with error " + error);
\r
1724 throw InputMethodExceptionFactory.CreateException(error);
\r
1729 /// Sends a key event to the associated text input UI control.
\r
1732 /// This function sends key down or up event with key mask to the client application. If forwardKey is true, this key event goes to the edit filed directly.
\r
1733 /// And if forwardKey is false, the ProcessKey event receives the key event before the edit field.
\r
1736 /// http://tizen.org/privilege/ime
\r
1738 /// <param name="keyCode">The key code to be sent</param>
\r
1739 /// <param name="keyMask">The modifier key mask</param>
\r
1740 /// <param name="forwardKey">The flag to send the key event directly to the edit field</param>
\r
1741 /// <exception cref="InvalidOperationException">
\r
1742 /// This can occur due to the following reasons:
\r
1743 /// 1) The application does not have the privilege to call this function
\r
1744 /// 2) IME main loop isn't started yet
\r
1746 public static void SendKeyEvent(KeyCode keyCode, KeyMask keyMask, bool forwardKey)
\r
1748 ErrorCode error = ImeSendKeyEvent(keyCode, keyMask, forwardKey);
\r
1749 if (error != ErrorCode.None)
\r
1751 Log.Error(LogTag, "SendEvent Failed with error " + error);
\r
1752 throw InputMethodExceptionFactory.CreateException(error);
\r
1757 /// Sends the text to the associated text input UI control.
\r
1760 /// http://tizen.org/privilege/ime
\r
1762 /// <param name="str">The UTF-8 string to be committed</param>
\r
1763 /// <exception cref="InvalidOperationException">
\r
1764 /// This can occur due to the following reasons:
\r
1765 /// 1) The application does not have the privilege to call this function
\r
1766 /// 2) IME main loop isn't started yet
\r
1768 public static void CommitString(string str)
\r
1770 ErrorCode error = ImeCommitString(str);
\r
1771 if (error != ErrorCode.None)
\r
1773 Log.Error(LogTag, "CommitString Failed with error " + error);
\r
1774 throw InputMethodExceptionFactory.CreateException(error);
\r
1779 /// Requests to show preedit string.
\r
1782 /// http://tizen.org/privilege/ime
\r
1784 /// <exception cref="InvalidOperationException">
\r
1785 /// This can occur due to the following reasons:
\r
1786 /// 1) The application does not have the privilege to call this function
\r
1787 /// 2) IME main loop isn't started yet
\r
1789 public static void ShowPreEditString()
\r
1791 ErrorCode error = ImeShowPreeditString();
\r
1792 if (error != ErrorCode.None)
\r
1794 Log.Error(LogTag, "ShowPreEditString Failed with error " + error);
\r
1795 throw InputMethodExceptionFactory.CreateException(error);
\r
1800 /// Requests to hide preedit string.
\r
1803 /// http://tizen.org/privilege/ime
\r
1805 /// <exception cref="InvalidOperationException">
\r
1806 /// This can occur due to the following reasons:
\r
1807 /// 1) The application does not have the privilege to call this function
\r
1808 /// 2) IME main loop isn't started yet
\r
1810 public static void HidePreEditString()
\r
1812 ErrorCode error = ImeHidePreeditString();
\r
1813 if (error != ErrorCode.None)
\r
1815 Log.Error(LogTag, "HidePreEditString Failed with error " + error);
\r
1816 throw InputMethodExceptionFactory.CreateException(error);
\r
1821 /// Updates a new preedit string.
\r
1824 /// http://tizen.org/privilege/ime
\r
1826 /// <param name="str">The UTF-8 string to be updated in preedit</param>
\r
1827 /// <param name="attrs">
\r
1828 /// The list which has ime_preedit_attribute lists, strings can be composed of multiple string attributes: underline, highlight color and reversal color.
\r
1829 /// The attrs can be null if no attributes to set
\r
1831 /// <exception cref="InvalidOperationException">
\r
1832 /// This can occur due to the following reasons:
\r
1833 /// 1) The application does not have the privilege to call this function
\r
1834 /// 2) IME main loop isn't started yet
\r
1835 /// 3) Invalid Parameter
\r
1837 public static void UpdatePreEditString(string str, List<PreEditAttribute> attrs)
\r
1839 IntPtr einaList = IntPtr.Zero;
\r
1840 GCHandle einaListHandle = GCHandle.Alloc(einaList);
\r
1841 List<GCHandle> attributeHandleList = new List<GCHandle>();
\r
1842 foreach (PreEditAttribute attribute in attrs)
\r
1844 ImePreEditAttributeStruct imePreEditAttribute = new ImePreEditAttributeStruct();
\r
1845 imePreEditAttribute.start = attribute.Start;
\r
1846 imePreEditAttribute.length = attribute.Length;
\r
1847 imePreEditAttribute.type = (int)attribute.Type;
\r
1848 imePreEditAttribute.value = attribute.Value;
\r
1849 GCHandle attributeHandle = GCHandle.Alloc(imePreEditAttribute);
\r
1850 attributeHandleList.Add(attributeHandle);
\r
1851 einaList = Interop.EinaList.EinaListAppend(einaListHandle.AddrOfPinnedObject(),attributeHandle.AddrOfPinnedObject());
\r
1853 ErrorCode error = ImeUpdatePreeditString(str, einaListHandle.AddrOfPinnedObject());
\r
1854 einaListHandle.Free();
\r
1855 foreach(GCHandle handle in attributeHandleList)
\r
1859 if (error != ErrorCode.None)
\r
1861 Log.Error(LogTag, "UpdatePreEditString Failed with error " + error);
\r
1862 throw InputMethodExceptionFactory.CreateException(error);
\r
1867 /// Requests the surrounding text from the position of the cursor, asynchronously.
\r
1870 /// http://tizen.org/privilege/ime
\r
1872 /// <param name="maxLenBefore">The maximum length of string to be retrieved before the cursor, -1 means unlimited</param>
\r
1873 /// <param name="maxLenAfter">The maximum length of string to be retrieved after the cursor, -1 means unlimited</param>
\r
1874 /// <exception cref="InvalidOperationException">
\r
1875 /// This can occur due to the following reasons:
\r
1876 /// 1) The application does not have the privilege to call this function
\r
1877 /// 2) IME main loop isn't started yet
\r
1879 public static void RequestSurroundingText(int maxLenBefore, int maxLenAfter)
\r
1881 ErrorCode error = ImeRequestSurroundingText(maxLenBefore, maxLenAfter);
\r
1882 if (error != ErrorCode.None)
\r
1884 Log.Error(LogTag, "RequestSurroundingText Failed with error " + error);
\r
1885 throw InputMethodExceptionFactory.CreateException(error);
\r
1890 /// Requests to delete surrounding text.
\r
1893 /// http://tizen.org/privilege/ime
\r
1895 /// <param name="offset">The offset value from the cursor position</param>
\r
1896 /// <param name="len">The length of the text to delete</param>
\r
1897 /// <exception cref="InvalidOperationException">
\r
1898 /// This can occur due to the following reasons:
\r
1899 /// 1) The application does not have the privilege to call this function
\r
1900 /// 2) IME main loop isn't started yet
\r
1901 /// 3) Invalid Parameter
\r
1903 public static void DeleteSurroundingText(int offset, int len)
\r
1905 ErrorCode error = ImeDeleteSurroundingText(offset, len);
\r
1906 if (error != ErrorCode.None)
\r
1908 Log.Error(LogTag, "DeleteSurroundingText Failed with error " + error);
\r
1909 throw InputMethodExceptionFactory.CreateException(error);
\r
1914 /// Gets the surrounding text from the position of the cursor, synchronously.
\r
1917 /// http://tizen.org/privilege/ime
\r
1919 /// <param name="maxLenBefore">The maximum length of string to be retrieved before the cursor, -1 means unlimited</param>
\r
1920 /// <param name="maxLenAfter">The maximum length of string to be retrieved after the cursor, -1 means unlimited</param>
\r
1921 /// <param name="text">The surrounding text</param>
\r
1922 /// <param name="cursorPosition">The cursor position</param>
\r
1923 /// <exception cref="InvalidOperationException">
\r
1924 /// This can occur due to the following reasons:
\r
1925 /// 1) The application does not have the privilege to call this function
\r
1926 /// 2) IME main loop isn't started yet
\r
1927 /// 3) Invalid Parameter
\r
1928 /// 4) Failed to obtain text due to out of memory
\r
1930 public static void GetSurroundingText(int maxLenBefore, int maxLenAfter, out string text, out int cursorPosition)
\r
1933 ErrorCode error = ImeGetSurroundingText(maxLenBefore, maxLenAfter, out txt, out cursorPosition);
\r
1934 if (error != ErrorCode.None)
\r
1936 Log.Error(LogTag, "GetSurroundingText Failed with error " + error);
\r
1937 throw InputMethodExceptionFactory.CreateException(error);
\r
1939 text = Marshal.PtrToStringAnsi(txt);
\r
1943 /// Requests to set selection.
\r
1946 /// http://tizen.org/privilege/ime
\r
1948 /// <param name="start">The start cursor position in text (in characters not bytes)</param>
\r
1949 /// <param name="end">The end cursor position in text (in characters not bytes)</param>
\r
1950 /// <exception cref="InvalidOperationException">
\r
1951 /// This can occur due to the following reasons:
\r
1952 /// 1) The application does not have the privilege to call this function
\r
1953 /// 2) IME main loop isn't started yet
\r
1954 /// 3) Invalid Parameter
\r
1956 public static void SetSelection(int start, int end)
\r
1958 ErrorCode error = ImeSetSelection(start, end);
\r
1959 if (error != ErrorCode.None)
\r
1961 Log.Error(LogTag, "SetSelection Failed with error " + error);
\r
1962 throw InputMethodExceptionFactory.CreateException(error);
\r
1967 /// This API returns the input panel main window.
\r
1970 /// http://tizen.org/privilege/ime
\r
1972 /// <returns>The input panel main window object on success, otherwise null</returns>
\r
1973 /// <exception cref="InvalidOperationException">
\r
1974 /// This can occur due to the following reasons:
\r
1975 /// 1) The application does not have the privilege to call this function
\r
1976 /// 2) IME main loop isn't started yet
\r
1977 /// 3) Operation Failed
\r
1979 public static EditorWindow GetMainWindow()
\r
1981 EditorWindow obj = new EditorWindow(ImeGetMainWindow());
\r
1982 ErrorCode error = (ErrorCode)Tizen.Internals.Errors.ErrorFacts.GetLastResult();
\r
1983 if (error != ErrorCode.None)
\r
1985 Log.Error(LogTag, "GetMainWindow Failed with error " + error);
\r
1986 throw InputMethodExceptionFactory.CreateException(error);
\r
1992 /// This API updates the input panel window's size information.
\r
1995 /// http://tizen.org/privilege/ime
\r
1997 /// <param name="portraitWidth">The width in portrait mode</param>
\r
1998 /// <param name="portraitHeight">The height in portrait mode</param>
\r
1999 /// <param name="landscapeWidth">The width in landscape mode</param>
\r
2000 /// <param name="landscapeHeight">The height in landscape mode</param>
\r
2001 /// <exception cref="InvalidOperationException">
\r
2002 /// This can occur due to the following reasons:
\r
2003 /// 1) The application does not have the privilege to call this function
\r
2004 /// 2) IME main loop isn't started yet
\r
2006 public static void SetSize(int portraitWidth, int portraitHeight, int landscapeWidth, int landscapeHeight)
\r
2008 ErrorCode error = ImeSetSize(portraitWidth, portraitHeight, landscapeWidth, landscapeHeight);
\r
2009 if (error != ErrorCode.None)
\r
2011 Log.Error(LogTag, "SetSize Failed with error " + error);
\r
2012 throw InputMethodExceptionFactory.CreateException(error);
\r
2017 /// Requests to create an option window from the input panel.
\r
2018 /// The input panel can call this function to open the option window. This function calls OptionWindowCreated Event with ImeOptionWindowType.Keyboard.
\r
2021 /// http://tizen.org/privilege/ime
\r
2023 /// <exception cref="InvalidOperationException">
\r
2024 /// This can occur due to the following reasons:
\r
2025 /// 1) The application does not have the privilege to call this function
\r
2026 /// 2) Operation failed
\r
2027 /// 3) IME main loop isn't started yet
\r
2028 /// 4) OptionWindowCreated event has not been set
\r
2030 /// <precondition>
\r
2031 /// OptionWindowCreated and OptionWindowDestroyed event should be set
\r
2032 /// </precondition>
\r
2033 public static void CreateOptionWindow()
\r
2035 ErrorCode error = ImeCreateOptionWindow();
\r
2036 if (error != ErrorCode.None)
\r
2038 Log.Error(LogTag, "CreapteOptionWindow Failed with error " + error);
\r
2039 throw InputMethodExceptionFactory.CreateException(error);
\r
2044 /// Requests to destroy an option window.
\r
2045 /// The input panel can call this function to close the option window which is created from either the input panel or Settings application.
\r
2048 /// http://tizen.org/privilege/ime
\r
2050 /// <param name="window">The option window to destroy</param>
\r
2051 /// <exception cref="InvalidOperationException">
\r
2052 /// This can occur due to the following reasons:
\r
2053 /// 1) The application does not have the privilege to call this function
\r
2054 /// 2) Invalid Parameter
\r
2055 /// 3) IME main loop isn't started yet
\r
2057 public static void DestroyOptionWindow(EditorWindow window)
\r
2059 ErrorCode error = ImeDestroyOptionWindow(window._handle);
\r
2060 if (error != ErrorCode.None)
\r
2062 Log.Error(LogTag, "DestroyOptionWindow Failed with error " + error);
\r
2063 throw InputMethodExceptionFactory.CreateException(error);
\r