2 * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved
4 * Licensed under the Apache License, Version 2.0 (the License);
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an AS IS BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
19 using System.Collections.Generic;
20 using System.Runtime.InteropServices;
21 using System.ComponentModel;
22 using static Interop.InputMethod;
24 namespace Tizen.Uix.InputMethod
27 /// Enumeration for the key codes.
28 /// If keycode & 0xff000000 == 0x01000000 then this key code is directly encoded to 24-bit UCS character. The UCS value is keycode & 0x00ffffff.
29 /// Defines the list of keys supported by the system. Note that certain keys may not be available on all the devices.
31 /// <since_tizen> 4 </since_tizen>
35 /// The Backspace key.
59 /// The Scroll lock key.
63 /// The System Request key.
75 /* Cursor control & motion */
81 /// The Left directional key.
85 /// The Up directional key.
89 /// The Right directional key.
93 /// The Down directional key.
97 /// The Prior, Previous key.
109 /// The Page Down key.
131 /// The Execute, Run, Do key.
155 /// The Cancel, Stop, Abort, Exit key.
167 /// The character set switch key.
169 Mode_switch = 0xFF7E,
171 /// The Number Lock key.
177 /// The Numpad Space key.
181 /// The Numpad Tab key.
185 /// The Numpad Enter key.
189 /// The Numpad Function 1 key.
193 /// The Numpad Function 2 key.
197 /// The Numpad Function 3 key.
201 /// The Numpad Function 4 key.
205 /// The Numpad Home key.
209 /// The Numpad Left key.
213 /// The Numpad Up key.
217 /// The Numpad Right key.
221 /// The Numpad Down key.
225 /// The Numpad Prior, Previous key.
229 /// The Numpad Page Up key.
233 /// The Numpad Next key.
237 /// The Numpad Page Down key.
239 KPPage_Down = 0xFF9B,
241 /// The Numpad End key.
245 /// The Numpad Begin key.
249 /// The Numpad Insert key.
253 /// The Numpad Delete key.
257 /// The Numpad Equal key.
261 /// The Numpad Multiply key.
265 /// The Numpad Add key.
269 /// The Numpad Separator key.
271 KPSeparator = 0xFFAC,
273 /// The Numpad Subtract key.
277 /// The Numpad Decimal key.
281 /// The Numpad Divide key.
285 /// The Numpad 0 key.
289 /// The Numpad 1 key.
293 /// The Numpad 2 key.
297 /// The Numpad 3 key.
301 /// The Numpad 4 key.
305 /// The Numpad 5 key.
309 /// The Numpad 6 key.
313 /// The Numpad 7 key.
317 /// The Numpad 8 key.
321 /// The Numpad 9 key.
325 /* Auxiliary Functions */
327 /// The Function 1 key.
331 /// The Function 2 key.
335 /// The Function 3 key.
339 /// The Function 4 key.
343 /// The Function 5 key.
347 /// The Function 6 key.
351 /// The Function 7 key.
355 /// The Function 8 key.
359 /// The Function 9 key.
363 /// The Function 10 key.
367 /// The Function 11 key.
371 /// The Function 12 key.
375 /// The Function 13 key.
379 /// The Function 14 key.
383 /// The Function 15 key.
387 /// The Function 16 key.
391 /// The Function 17 key.
395 /// The Function 18 key.
399 /// The Function 19 key.
403 /// The Function 20 key.
407 /// The Function 21 key.
411 /// The Function 22 key.
415 /// The Function 23 key.
419 /// The Function 24 key.
423 /// The Function 25 key.
427 /// The Function 26 key.
431 /// The Function 27 key.
435 /// The Function 28 key.
439 /// The Function 29 key.
443 /// The Function 30 key.
447 /// The Function 31 key.
451 /// The Function 32 key.
455 /// The Function 33 key.
459 /// The Function 34 key.
463 /// The Function 35 key.
469 /// The Left Shift key.
473 /// The Right Shift key.
477 /// The Left Control key.
481 /// The Right Control key.
485 /// The Caps Lock key.
489 /// The Shift Lock key.
493 /// The Left Meta key.
497 /// The Right Meta key.
501 /// The Left Alt key.
505 /// The Right Alt key.
509 /// The Left Super key.
513 /// The Right Super key.
517 /// The Left Hyper key.
521 /// The Right Hyper key.
531 /// The Exclamation key.
535 /// The Quotedbl key.
539 /// The Number Sign key.
551 /// The Ampersand key.
555 /// The Apostrophe key.
559 /// The Parenleft key.
563 /// The Parenright key.
567 /// The Asterisk key.
635 /// The Semicolon key.
651 /// The Question key.
763 /// The Left Bracket key.
767 /// The Backslash key.
771 /// The Right Bracket key.
773 BracketRight = 0x05d,
775 /// The Circumflex key.
779 /// The Underscore key.
891 /// The Left Brace key.
899 /// The Right Brace key.
909 /// Enumeration for the key masks.
910 /// The key masks indicate which modifier keys are pressed down during the keyboard hit. The special MASK_RELEASED indicates the key release event.
912 /// <since_tizen> 4 </since_tizen>
916 /// Key press event without the modifier key.
920 /// The Shift key is pressed down.
924 /// The CapsLock key is pressed down.
928 /// The Control key is pressed down.
932 /// The Alt key is pressed down.
936 /// The Meta key is pressed down.
940 /// The Win key (between Control and Alt) is pressed down.
944 /// The Hyper key is pressed down.
948 /// The NumLock key is pressed down.
952 /// Key release event.
954 Released = (1 << 15),
958 /// This class contains the API's related to the IME (Input method editor).
960 /// <since_tizen> 4 </since_tizen>
961 public static class InputMethodEditor
963 private static ImeCallbackStructGCHandle _imeCallbackStructGCHandle = new ImeCallbackStructGCHandle();
964 private static event EventHandler<FocusedInEventArgs> _focusIn;
965 private static ImeFocusedInCb _imeFocusedInDelegate;
966 private static event EventHandler<FocusedOutEventArgs> _focusOut;
967 private static ImeFocusedOutCb _imeFocusedOutDelegate;
968 private static event EventHandler<SurroundingTextUpdatedEventArgs> _surroundingTextUpdated;
969 private static ImeSurroundingTextUpdatedCb _imeSurroundingTextUpdatedDelegate;
970 private static event EventHandler<EventArgs> _inputContextReset;
971 private static ImeInputContextResetCb _imeInputContextResetDelegate;
972 private static event EventHandler<CursorPositionUpdatedEventArgs> _cursorPositionUpdated;
973 private static ImeCursorPositionUpdatedCb _imeCursorPositionUpdatedDelegate;
974 private static event EventHandler<LanguageSetEventArgs> _langaugeSet;
975 private static ImeLanguageSetCb _imeLanguageSetDelegate;
976 private static event EventHandler<SetDataEventArgs> _imDataSet;
977 private static ImeImdataSetCb _imeDataSetDelegate;
978 private static event EventHandler<LayoutSetEventArgs> _layoutSet;
979 private static ImeLayoutSetCb _imeLayoutSetDelegate;
980 private static event EventHandler<ReturnKeySetEventArgs> _returnKeyTypeSet;
981 private static ImeReturnKeySetCb _imeReturnKeySetDelegate;
982 private static event EventHandler<ReturnKeyStateSetEventArgs> _returnKeyStateSet;
983 private static ImeReturnKeyStateSetCb _imeReturnKeyStateSetDelegate;
984 private static ImeProcessKeyEventCb _imeProcessKeyDelegate;
985 private static event EventHandler<DisplayLanguageChangedEventArgs> _displayLanguageChanged;
986 private static ImeDisplayLanguageChangedCb _imeDisplayLanguageChangedDelegate;
987 private static event EventHandler<RotationChangedEventArgs> _rotationDegreeChanged;
988 private static ImeRotationChangedCb _imeRotationChangedDelegate;
989 private static event EventHandler<AccessibilityStateChangedEventArgs> _accessibilityStateChanged;
990 private static ImeAccessibilityStateChangedCb _imeAccessibilityStateChangedDelegate;
991 private static event EventHandler<PredictionHintUpdatedEventArgs> _predictionHintUpdated;
992 private static ImePredictionHintSetCb _imePredictionHintSetDelegate;
993 private static event EventHandler<PredictionHintDataUpdatedEventArgs> _predictionHintDataUpdated;
994 private static ImePredictionHintDataSetCb _imePredictionHintDataSetDelegate;
995 private static event EventHandler<MimeTypeUpdateRequestedEventArgs> _mimeTypeUpdateRequested;
996 private static ImeMimeTypeSetRequestCb _imeMimeTypeSetRequestDelegate;
997 private static ImeLanguageRequestedCb _imeLanguageRequestedDelegate;
998 private static OutAction<string> _languageRequestedDelegate;
999 private static BoolAction<KeyCode, KeyMask, InputMethodDeviceInformation> _processKeyDelagate;
1000 private static ImeImdataRequestedCb _imeImDataRequestedDelegate;
1001 private static OutArrayAction<byte> _imDataRequestedDelegate;
1002 private static ImeGeometryRequestedCb _imeGeometryRequestedDelegate;
1003 private static OutAction<Rect> _geometryRequestedDelegate;
1004 private static Action _userCreate;
1005 private static Action _userTerminate;
1006 private static Action<ContextId, InputMethodContext> _userShow;
1007 private static Action<ContextId> _userHide;
1008 private static ImeCreateCb _create = (IntPtr userData) =>
1010 Log.Info(LogTag, "In Create Delegate");
1011 _userCreate?.Invoke();
1013 private static ImeTerminateCb _terminate = (IntPtr userData) =>
1015 Log.Info(LogTag, "In terminate Delegate");
1016 _userTerminate?.Invoke();
1017 _imeCallbackStructGCHandle.Dispose();
1019 private static ImeShowCb _show = (int contextId, IntPtr context, IntPtr userData) =>
1021 Log.Info(LogTag, "In Show Delegate");
1022 _userShow?.Invoke(new ContextId(contextId), new InputMethodContext(context));
1024 private static ImeHideCb _hide = (int contextId, IntPtr userData) =>
1026 Log.Info(LogTag, "In Hide Delegate");
1027 _userHide?.Invoke(new ContextId(contextId));
1031 /// Structure representing the ContextId.
1033 /// <since_tizen> 4 </since_tizen>
1034 public struct ContextId : IEquatable<ContextId>
1036 internal ContextId(int id)
1048 /// Compares whether the ContextIds are equal.
1050 /// <param name="other">The ContextId to compare with this instance.</param>
1051 /// <returns>true if the ContextIds is the same; otherwise, false.</returns>
1052 /// <since_tizen> 4 </since_tizen>
1053 public bool Equals(ContextId other)
1055 return this.Id == other.Id;
1060 /// Rectangle representing the position and size of the UI control.
1062 /// <since_tizen> 4 </since_tizen>
1066 /// The X position in the screen.
1068 /// <since_tizen> 4 </since_tizen>
1072 /// The Y position in the screen.
1074 /// <since_tizen> 4 </since_tizen>
1078 /// The window width.
1080 /// <since_tizen> 4 </since_tizen>
1084 /// The window height.
1086 /// <since_tizen> 4 </since_tizen>
1091 /// An action with 1 out parameter.
1093 /// <typeparam name="T">Generic Type.</typeparam>
1094 /// <param name="a">The out parameter.</param>
1095 /// <since_tizen> 4 </since_tizen>
1096 public delegate void OutAction<T>(out T a);
1099 /// An action with an array out parameter.
1101 /// <typeparam name="T">Generic Type.</typeparam>
1102 /// <param name="a">The out parameter 1.</param>
1103 /// <since_tizen> 4 </since_tizen>
1104 public delegate void OutArrayAction<T>(out T[] a);
1107 /// An action with 3 input parameters returning a bool.
1109 /// <typeparam name="T">Generic type for parameter 1.</typeparam>
1110 /// <typeparam name="T1">Generic type for parameter 2.</typeparam>
1111 /// <typeparam name="T2">Generic type for parameter 3.</typeparam>
1112 /// <param name="a">The input parameter 1.</param>
1113 /// <param name="b">The input parameter 2.</param>
1114 /// <param name="c">The input parameter 3.</param>
1115 /// <returns></returns>
1116 /// <since_tizen> 4 </since_tizen>
1117 public delegate bool BoolAction<T, T1, T2>(T a, T1 b, T2 c);
1120 /// Called when an associated text input UI control has focus.
1122 /// <since_tizen> 4 </since_tizen>
1123 public static event EventHandler<FocusedInEventArgs> FocusedIn
1127 _imeFocusedInDelegate = (int contextId, IntPtr userData) =>
1129 FocusedInEventArgs args = new FocusedInEventArgs(contextId);
1130 _focusIn?.Invoke(null, args);
1132 ErrorCode error = ImeEventSetFocusedInCb(_imeFocusedInDelegate, IntPtr.Zero);
1133 if (error != ErrorCode.None)
1135 Log.Error(LogTag, "Add FocusedIn Failed with error " + error);
1149 /// Called when an associated text input UI control loses focus.
1151 /// <since_tizen> 4 </since_tizen>
1152 public static event EventHandler<FocusedOutEventArgs> FocusedOut
1156 _imeFocusedOutDelegate = (int contextId, IntPtr userData) =>
1158 FocusedOutEventArgs args = new FocusedOutEventArgs(contextId);
1159 _focusOut?.Invoke(null, args);
1161 ErrorCode error = ImeEventSetFocusedOutCb(_imeFocusedOutDelegate, IntPtr.Zero);
1162 if (error != ErrorCode.None)
1164 Log.Error(LogTag, "Add FocusedOut Failed with error " + error);
1178 /// Called when an associated text input UI control responds to a request with the surrounding text.
1180 /// <since_tizen> 4 </since_tizen>
1181 public static event EventHandler<SurroundingTextUpdatedEventArgs> SurroundingTextUpdated
1185 _imeSurroundingTextUpdatedDelegate = (int contextId, IntPtr text, int cursorPos, IntPtr userData) =>
1187 SurroundingTextUpdatedEventArgs args = new SurroundingTextUpdatedEventArgs(contextId, Marshal.PtrToStringAnsi(text), cursorPos);
1188 _surroundingTextUpdated?.Invoke(null, args);
1190 ErrorCode error = ImeEventSetSurroundingTextUpdatedCb(_imeSurroundingTextUpdatedDelegate, IntPtr.Zero);
1191 if (error != ErrorCode.None)
1193 Log.Error(LogTag, "Add SurroundingTextUpdated Failed with error " + error);
1197 _surroundingTextUpdated += value;
1202 _surroundingTextUpdated -= value;
1207 /// Called to reset the input context of an associated text input UI control.
1209 /// <since_tizen> 4 </since_tizen>
1210 public static event EventHandler<EventArgs> InputContextReset
1214 _imeInputContextResetDelegate = (IntPtr userData) =>
1216 _inputContextReset?.Invoke(null, EventArgs.Empty);
1218 ErrorCode error = ImeEventSetInputContextResetCb(_imeInputContextResetDelegate, IntPtr.Zero);
1219 if (error != ErrorCode.None)
1221 Log.Error(LogTag, "Add InputContextReset Failed with error " + error);
1225 _inputContextReset += value;
1230 _inputContextReset -= value;
1235 /// Called when the position of the cursor in an associated text input UI control changes.
1237 /// <since_tizen> 4 </since_tizen>
1238 public static event EventHandler<CursorPositionUpdatedEventArgs> CursorPositionUpdated
1242 _imeCursorPositionUpdatedDelegate = (int cursorPos, IntPtr userData) =>
1244 CursorPositionUpdatedEventArgs args = new CursorPositionUpdatedEventArgs(cursorPos);
1245 _cursorPositionUpdated?.Invoke(null, args);
1247 ErrorCode error = ImeEventSetCursorPositionUpdatedCb(_imeCursorPositionUpdatedDelegate, IntPtr.Zero);
1248 if (error != ErrorCode.None)
1250 Log.Error(LogTag, "Add CursorPositionUpdated Failed with error " + error);
1254 _cursorPositionUpdated += value;
1259 _cursorPositionUpdated -= value;
1264 /// Called to set the preferred language to the input panel.
1265 /// It will only be called when the client application changes the edit field's language attribute after the input panel is shown.
1267 /// <since_tizen> 4 </since_tizen>
1268 public static event EventHandler<LanguageSetEventArgs> LanguageSet
1272 _imeLanguageSetDelegate = (InputPanelLanguage language, IntPtr userData) =>
1274 LanguageSetEventArgs args = new LanguageSetEventArgs(language);
1275 _langaugeSet?.Invoke(null, args);
1277 ErrorCode error = ImeEventSetLanguageSetCb(_imeLanguageSetDelegate, IntPtr.Zero);
1278 if (error != ErrorCode.None)
1280 Log.Error(LogTag, "Add LanguageSet Failed with error " + error);
1284 _langaugeSet += value;
1289 _langaugeSet -= value;
1294 /// Called to set the application specific data to deliver to the input panel.
1296 /// <since_tizen> 4 </since_tizen>
1297 public static event EventHandler<SetDataEventArgs> DataSet
1301 _imeDataSetDelegate = (IntPtr data, uint dataLength, IntPtr userData) =>
1303 byte[] destination = new byte[dataLength];
1304 Marshal.Copy(data, destination, 0, (int)dataLength);
1305 SetDataEventArgs args = new SetDataEventArgs(destination, dataLength);
1306 _imDataSet?.Invoke(null, args);
1308 ErrorCode error = ImeEventSetImdataSetCb(_imeDataSetDelegate, IntPtr.Zero);
1309 if (error != ErrorCode.None)
1311 Log.Error(LogTag, "Add DataSet Failed with error " + error);
1315 _imDataSet += value;
1320 _imDataSet -= value;
1325 /// Called when an associated text input UI control requests the input panel to set its layout.
1326 /// It will only be called when the client application changes the edit field's layout attribute after the input panel is shown.
1328 /// <since_tizen> 4 </since_tizen>
1329 public static event EventHandler<LayoutSetEventArgs> LayoutSet
1333 _imeLayoutSetDelegate = (InputPanelLayout layout, IntPtr userData) =>
1335 LayoutSetEventArgs args = new LayoutSetEventArgs(layout);
1336 _layoutSet?.Invoke(null, args);
1338 ErrorCode error = ImeEventSetLayoutSetCb(_imeLayoutSetDelegate, IntPtr.Zero);
1339 if (error != ErrorCode.None)
1341 Log.Error(LogTag, "Add LayoutSet Failed with error " + error);
1345 _layoutSet += value;
1350 _layoutSet -= value;
1355 /// Called when an associated text input UI control requests the input panel to set the Return key label.
1356 /// The input panel can show the text or an image on the Return button, according to the Return key action.
1358 /// <since_tizen> 4 </since_tizen>
1359 public static event EventHandler<ReturnKeySetEventArgs> ReturnKeySet
1363 _imeReturnKeySetDelegate = (InputPanelReturnKey type, IntPtr userData) =>
1365 ReturnKeySetEventArgs args = new ReturnKeySetEventArgs(type);
1366 _returnKeyTypeSet?.Invoke(null, args);
1368 ErrorCode error = ImeEventSetReturnKeySetCb(_imeReturnKeySetDelegate, IntPtr.Zero);
1369 if (error != ErrorCode.None)
1371 Log.Error(LogTag, "Add ReturnKeySet Failed with error " + error);
1375 _returnKeyTypeSet += value;
1380 _returnKeyTypeSet -= value;
1385 /// Called when an associated text input UI control requests the input panel to enable or disable the Return key state.
1387 /// <since_tizen> 4 </since_tizen>
1388 public static event EventHandler<ReturnKeyStateSetEventArgs> ReturnKeyStateSet
1392 _imeReturnKeyStateSetDelegate = (bool state, IntPtr userData) =>
1394 ReturnKeyStateSetEventArgs args = new ReturnKeyStateSetEventArgs(state);
1395 _returnKeyStateSet?.Invoke(null, args);
1397 ErrorCode error = ImeEventSetReturnKeyStateSetCb(_imeReturnKeyStateSetDelegate, IntPtr.Zero);
1398 if (error != ErrorCode.None)
1400 Log.Error(LogTag, "Add ReturnKeyStateSet Failed with error " + error);
1404 _returnKeyStateSet += value;
1409 _returnKeyStateSet -= value;
1414 /// Called when the system display language is changed.
1416 /// <since_tizen> 4 </since_tizen>
1417 public static event EventHandler<DisplayLanguageChangedEventArgs> DisplayLanguageChanged
1421 _imeDisplayLanguageChangedDelegate = (IntPtr language, IntPtr userData) =>
1423 DisplayLanguageChangedEventArgs args = new DisplayLanguageChangedEventArgs(Marshal.PtrToStringAnsi(language));
1424 _displayLanguageChanged?.Invoke(null, args);
1426 ErrorCode error = ImeEventSetDisplayLanguageChangedCb(_imeDisplayLanguageChangedDelegate, IntPtr.Zero);
1427 if (error != ErrorCode.None)
1429 Log.Error(LogTag, "Add DisplayLanguageChanged Failed with error " + error);
1433 _displayLanguageChanged += value;
1438 _displayLanguageChanged -= value;
1443 /// Called when the device is rotated.
1445 /// <since_tizen> 4 </since_tizen>
1446 public static event EventHandler<RotationChangedEventArgs> RotationChanged
1450 _imeRotationChangedDelegate = (int degree, IntPtr userData) =>
1452 RotationChangedEventArgs args = new RotationChangedEventArgs(degree);
1453 _rotationDegreeChanged?.Invoke(null, args);
1455 ErrorCode error = ImeEventSetRotationChangedCb(_imeRotationChangedDelegate, IntPtr.Zero);
1456 if (error != ErrorCode.None)
1458 Log.Error(LogTag, "Add RotationChanged Failed with error " + error);
1462 _rotationDegreeChanged += value;
1467 _rotationDegreeChanged -= value;
1472 /// Called when Accessibility in settings application is on or off.
1474 /// <since_tizen> 4 </since_tizen>
1475 public static event EventHandler<AccessibilityStateChangedEventArgs> AccessibilityStateChanged
1479 _imeAccessibilityStateChangedDelegate = (bool state, IntPtr userData) =>
1481 AccessibilityStateChangedEventArgs args = new AccessibilityStateChangedEventArgs(state);
1482 _accessibilityStateChanged?.Invoke(null, args);
1484 ErrorCode error = ImeEventSetAccessibilityStateChangedCb(_imeAccessibilityStateChangedDelegate, IntPtr.Zero);
1485 if (error != ErrorCode.None)
1487 Log.Error(LogTag, "Add AccessibilityStateChanged Failed with error " + error);
1491 _accessibilityStateChanged += value;
1496 _accessibilityStateChanged -= value;
1501 /// Sets the languageRequested action.
1503 /// <param name="languageRequested">
1504 /// Called when an associated text input UI control requests the language from the input panel, requesting for language code.
1506 /// <since_tizen> 4 </since_tizen>
1507 public static void SetLanguageRequestedCallback(OutAction<string> languageRequested)
1509 _imeLanguageRequestedDelegate = (IntPtr userData, out IntPtr langCode) =>
1512 _languageRequestedDelegate(out langauage);
1513 langCode = (IntPtr)Marshal.StringToHGlobalAnsi(langauage);
1515 ErrorCode error = ImeEventSetLanguageRequestedCallbackCb(_imeLanguageRequestedDelegate, IntPtr.Zero);
1516 if (error != ErrorCode.None)
1518 Log.Error(LogTag, "Add SetLanguageRequestedCallback Failed with error " + error);
1520 _languageRequestedDelegate = languageRequested;
1524 /// Sets the processKey action.
1525 /// If the key event is from the external device, DeviceInfo will have its name, class, and subclass information.
1527 /// <param name="processKey">
1528 /// The action is called when the key event is received from the external devices or the SendKey function.
1529 /// This Event processes the key event before an associated text input UI control does.
1531 /// <since_tizen> 4 </since_tizen>
1532 public static void SetProcessKeyCallback(BoolAction<KeyCode, KeyMask, InputMethodDeviceInformation> processKey)
1534 _imeProcessKeyDelegate = (KeyCode keyCode, KeyMask keyMask, IntPtr devInfo, IntPtr userData) =>
1536 return _processKeyDelagate(keyCode, keyMask, new InputMethodDeviceInformation(devInfo));
1538 ErrorCode error = ImeEventSetProcessKeyEventCb(_imeProcessKeyDelegate, IntPtr.Zero);
1539 if (error != ErrorCode.None)
1541 Log.Error(LogTag, "Add ProcessKey Failed with error " + error);
1543 _processKeyDelagate = processKey;
1547 /// Sets the imDataRequested action.
1549 /// <param name="imDataRequested">
1550 /// 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.
1552 /// <since_tizen> 4 </since_tizen>
1553 public static void SetDataRequestedCallback(OutArrayAction<byte> imDataRequested)
1555 _imeImDataRequestedDelegate = (IntPtr userData, out IntPtr data, out uint dataLength) =>
1558 _imDataRequestedDelegate(out dataArr);
1559 data = Marshal.AllocHGlobal(dataArr.Length);
1560 Marshal.Copy(dataArr, 0, data, dataArr.Length);
1561 dataLength = (uint)dataArr.Length;
1563 ErrorCode error = ImeEventSetImdataRequestedCb(_imeImDataRequestedDelegate, IntPtr.Zero);
1564 if (error != ErrorCode.None)
1566 Log.Error(LogTag, "Add SetDataRequestedCallback Failed with error " + error);
1568 _imDataRequestedDelegate = imDataRequested;
1572 /// Sets the GeometryRequested action.
1574 /// <param name="geometryRequested">
1575 /// Called when an associated text input UI control requests the position and size from the input panel, requesting for x, y, w, h values.
1577 /// <since_tizen> 4 </since_tizen>
1578 public static void SetGeometryRequestedCallback(OutAction<Rect> geometryRequested)
1580 _imeGeometryRequestedDelegate = (IntPtr userData, out int x, out int y, out int w, out int h) =>
1582 Rect rect = new Rect();
1583 _geometryRequestedDelegate(out rect);
1589 ErrorCode error = ImeEventSetGeometryRequestedCallbackCb(_imeGeometryRequestedDelegate, IntPtr.Zero);
1590 if (error != ErrorCode.None)
1592 Log.Error(LogTag, "Add SetGeometryRequestedCallback Failed with error " + error);
1594 _geometryRequestedDelegate = geometryRequested;
1598 /// Runs the main loop of the IME application.
1599 /// This function starts to run the IME application's main loop.
1602 /// http://tizen.org/privilege/ime
1605 /// This API is a blocking call, as it starts the main loop of the application.
1607 /// <param name="create">This is called to initialize the IME application before the main loop starts up.</param>
1608 /// <param name="terminate">This is called when the IME application is terminated.</param>
1609 /// <param name="show">
1610 /// This is called when the IME application is shown.
1611 /// It provides the context information and the context ID.
1613 /// <param name="hide">
1614 /// This is called when the IME application is hidden.
1615 /// It provides the context ID.
1617 /// <exception cref="InvalidOperationException">
1618 /// This can occur due to the following reasons:
1619 /// 1) The application does not have the privilege to call this function.
1620 /// 2) Operation failed.
1622 /// <since_tizen> 4 </since_tizen>
1623 public static void Run(Action create, Action terminate, Action<ContextId, InputMethodContext> show, Action<ContextId> hide)
1625 _userCreate = create;
1626 _userTerminate = terminate;
1629 _imeCallbackStructGCHandle._imeCallbackStruct.create = _create;
1630 _imeCallbackStructGCHandle._imeCallbackStruct.terminate = _terminate;
1631 _imeCallbackStructGCHandle._imeCallbackStruct.hide = _hide;
1632 _imeCallbackStructGCHandle._imeCallbackStruct.show = _show;
1634 ImeSetDotnetFlag(true);
1635 ErrorCode error = ImeRun(ref _imeCallbackStructGCHandle._imeCallbackStruct, IntPtr.Zero);
1636 if (error != ErrorCode.None)
1638 Log.Error(LogTag, "Run Failed with error " + error);
1639 throw InputMethodExceptionFactory.CreateException(error);
1645 /// Sends a key event to the associated text input UI control.
1648 /// This function sends a key down or up event with the key mask to the client application. If forwardKey is true, this key event goes to the edit filed directly.
1649 /// And if forwardKey is false, the ProcessKey event receives the key event before the edit field.
1652 /// http://tizen.org/privilege/ime
1654 /// <param name="keyCode">The key code to be sent.</param>
1655 /// <param name="keyMask">The modifier key mask.</param>
1656 /// <param name="forwardKey">The flag to send the key event directly to the edit field.</param>
1657 /// <exception cref="InvalidOperationException">
1658 /// This can occur due to the following reasons:
1659 /// 1) The application does not have the privilege to call this function.
1660 /// 2) The IME main loop has not started yet.
1662 /// <since_tizen> 4 </since_tizen>
1663 public static void SendKeyEvent(KeyCode keyCode, KeyMask keyMask, bool forwardKey = false)
1665 ErrorCode error = ImeSendKeyEvent(keyCode, keyMask, forwardKey);
1666 if (error != ErrorCode.None)
1668 Log.Error(LogTag, "SendEvent Failed with error " + error);
1669 throw InputMethodExceptionFactory.CreateException(error);
1674 /// Sends the text to the associated text input UI control.
1677 /// http://tizen.org/privilege/ime
1679 /// <param name="str">The string to be committed.</param>
1680 /// <exception cref="InvalidOperationException">
1681 /// This can occur due to the following reasons:
1682 /// 1) The application does not have the privilege to call this function.
1683 /// 2) The IME main loop has not started yet.
1685 /// <since_tizen> 4 </since_tizen>
1686 public static void CommitString(string str)
1688 ErrorCode error = ImeCommitString(str);
1689 if (error != ErrorCode.None)
1691 Log.Error(LogTag, "CommitString Failed with error " + error);
1692 throw InputMethodExceptionFactory.CreateException(error);
1697 /// Requests to show the pre-edit string.
1700 /// http://tizen.org/privilege/ime
1702 /// <exception cref="InvalidOperationException">
1703 /// This can occur due to the following reasons:
1704 /// 1) The application does not have the privilege to call this function.
1705 /// 2) The IME main loop has not started yet.
1707 /// <since_tizen> 4 </since_tizen>
1708 public static void ShowPreEditString()
1710 ErrorCode error = ImeShowPreeditString();
1711 if (error != ErrorCode.None)
1713 Log.Error(LogTag, "ShowPreEditString Failed with error " + error);
1714 throw InputMethodExceptionFactory.CreateException(error);
1719 /// Requests to hide the pre-edit string.
1722 /// http://tizen.org/privilege/ime
1724 /// <exception cref="InvalidOperationException">
1725 /// This can occur due to the following reasons:
1726 /// 1) The application does not have the privilege to call this function.
1727 /// 2) The IME main loop has not started yet.
1729 /// <since_tizen> 4 </since_tizen>
1730 public static void HidePreEditString()
1732 ErrorCode error = ImeHidePreeditString();
1733 if (error != ErrorCode.None)
1735 Log.Error(LogTag, "HidePreEditString Failed with error " + error);
1736 throw InputMethodExceptionFactory.CreateException(error);
1741 /// Updates a new pre-edit string.
1744 /// http://tizen.org/privilege/ime
1746 /// <param name="str">The string to be updated in pre-edit.</param>
1747 /// <param name="attrs">
1748 /// The list which has ime_preedit_attribute lists, strings can be composed of multiple string attributes: underline, highlight color, and reversal color.
1749 /// The attrs list can be empty if no attributes to set.
1751 /// <exception cref="InvalidOperationException">
1752 /// This can occur due to the following reasons:
1753 /// 1) The application does not have the privilege to call this function.
1754 /// 2) The IME main loop has not started yet.
1755 /// 3) Invalid parameter.
1757 /// <since_tizen> 4 </since_tizen>
1758 public static void UpdatePreEditString(string str, IEnumerable<PreEditAttribute> attrs)
1760 IntPtr einaList = IntPtr.Zero;
1761 List<GCHandle> attributeHandleList = new List<GCHandle>();
1762 foreach (PreEditAttribute attribute in attrs)
1764 ImePreEditAttributeStruct imePreEditAttribute = new ImePreEditAttributeStruct();
1765 imePreEditAttribute.start = attribute.Start;
1766 imePreEditAttribute.length = attribute.Length;
1767 imePreEditAttribute.type = (int)attribute.Type;
1768 imePreEditAttribute.value = attribute.Value;
1769 GCHandle attributeHandle = GCHandle.Alloc(imePreEditAttribute, GCHandleType.Pinned);
1770 attributeHandleList.Add(attributeHandle);
1771 einaList = Interop.EinaList.EinaListAppend(einaList, attributeHandle.AddrOfPinnedObject());
1773 ErrorCode error = ImeUpdatePreeditString(str, einaList);
1774 foreach (GCHandle handle in attributeHandleList)
1778 if (error != ErrorCode.None)
1780 Log.Error(LogTag, "UpdatePreEditString Failed with error " + error);
1781 throw InputMethodExceptionFactory.CreateException(error);
1786 /// Requests the surrounding text from the position of the cursor, asynchronously.
1789 /// http://tizen.org/privilege/ime
1791 /// <param name="maxLenBefore">The maximum length of the string to be retrieved before the cursor, -1 means unlimited.</param>
1792 /// <param name="maxLenAfter">The maximum length of the string to be retrieved after the cursor, -1 means unlimited.</param>
1793 /// <exception cref="InvalidOperationException">
1794 /// This can occur due to the following reasons:
1795 /// 1) The application does not have the privilege to call this function.
1796 /// 2) The IME main loop has not started yet.
1799 /// The requested surrounding text can be received using the SurroundingTextUpdated event, only if it is set.
1800 /// </postcondition>
1801 /// <since_tizen> 4 </since_tizen>
1802 public static void RequestSurroundingText(int maxLenBefore, int maxLenAfter)
1804 ErrorCode error = ImeRequestSurroundingText(maxLenBefore, maxLenAfter);
1805 if (error != ErrorCode.None)
1807 Log.Error(LogTag, "RequestSurroundingText Failed with error " + error);
1808 throw InputMethodExceptionFactory.CreateException(error);
1813 /// Requests to delete the surrounding text.
1816 /// http://tizen.org/privilege/ime
1818 /// <param name="offset">The offset value from the cursor position.</param>
1819 /// <param name="len">The length of the text to delete.</param>
1820 /// <exception cref="InvalidOperationException">
1821 /// This can occur due to the following reasons:
1822 /// 1) The application does not have the privilege to call this function.
1823 /// 2) The IME main loop has not started yet.
1824 /// 3) Invalid parameter.
1826 /// <since_tizen> 4 </since_tizen>
1827 public static void DeleteSurroundingText(int offset, int len)
1829 ErrorCode error = ImeDeleteSurroundingText(offset, len);
1830 if (error != ErrorCode.None)
1832 Log.Error(LogTag, "DeleteSurroundingText Failed with error " + error);
1833 throw InputMethodExceptionFactory.CreateException(error);
1838 /// Gets the surrounding text from the position of the cursor, synchronously.
1841 /// http://tizen.org/privilege/ime
1843 /// <param name="maxLenBefore">The maximum length of the string to be retrieved before the cursor, -1 means unlimited.</param>
1844 /// <param name="maxLenAfter">The maximum length of the string to be retrieved after the cursor, -1 means unlimited.</param>
1845 /// <param name="text">The surrounding text.</param>
1846 /// <param name="cursorPosition">The cursor position.</param>
1847 /// <exception cref="InvalidOperationException">
1848 /// This can occur due to the following reasons:
1849 /// 1) The application does not have the privilege to call this function.
1850 /// 2) The IME main loop has not started yet.
1851 /// 3) Invalid parameter.
1852 /// 4) Failed to obtain text due to out of memory.
1854 /// <since_tizen> 4 </since_tizen>
1855 public static void GetSurroundingText(int maxLenBefore, int maxLenAfter, out string text, out int cursorPosition)
1858 ErrorCode error = ImeGetSurroundingText(maxLenBefore, maxLenAfter, out txt, out cursorPosition);
1859 if (error != ErrorCode.None)
1861 Log.Error(LogTag, "GetSurroundingText Failed with error " + error);
1862 throw InputMethodExceptionFactory.CreateException(error);
1864 text = Marshal.PtrToStringAnsi(txt);
1868 /// Requests to set the selection.
1871 /// http://tizen.org/privilege/ime
1873 /// <param name="start">The start cursor position in text (in characters not bytes).</param>
1874 /// <param name="end">The end cursor position in text (in characters not bytes).</param>
1875 /// <exception cref="InvalidOperationException">
1876 /// This can occur due to the following reasons:
1877 /// 1) The application does not have the privilege to call this function.
1878 /// 2) The IME main loop has not started yet.
1879 /// 3) Invalid parameter.
1881 /// <since_tizen> 4 </since_tizen>
1882 public static void SetSelection(int start, int end)
1884 ErrorCode error = ImeSetSelection(start, end);
1885 if (error != ErrorCode.None)
1887 Log.Error(LogTag, "SetSelection Failed with error " + error);
1888 throw InputMethodExceptionFactory.CreateException(error);
1893 /// This API returns the input panel main window.
1896 /// http://tizen.org/privilege/ime
1898 /// <returns>The input panel main window object on success, otherwise null.</returns>
1899 /// <exception cref="InvalidOperationException">
1900 /// This can occur due to the following reasons:
1901 /// 1) The application does not have the privilege to call this function.
1902 /// 2) The IME main loop has not started yet.
1903 /// 3) Operation failed.
1905 /// <since_tizen> 4 </since_tizen>
1906 public static EditorWindow GetMainWindow()
1908 EditorWindow._handle = ImeGetMainWindow();
1909 EditorWindow obj = new EditorWindow();
1910 ErrorCode error = (ErrorCode)Tizen.Internals.Errors.ErrorFacts.GetLastResult();
1911 if (error != ErrorCode.None)
1913 Log.Error(LogTag, "GetMainWindow Failed with error " + error);
1914 throw InputMethodExceptionFactory.CreateException(error);
1920 /// Sends the request to hide the IME.
1923 /// http://tizen.org/privilege/ime
1925 /// <exception cref="InvalidOperationException">
1926 /// This can occur due to the following reasons:
1927 /// 1) The application does not have the privilege to call this function.
1928 /// 2) The IME main loop has not started yet.
1930 /// <since_tizen> 5 </since_tizen>
1931 public static void RequestHide()
1933 ErrorCode error = ImeRequestHide();
1934 if (error != ErrorCode.None)
1936 Log.Error(LogTag, "RequestHide Failed with error " + error);
1937 throw InputMethodExceptionFactory.CreateException(error);
1942 /// This API requests the InputMethodEditor to initialize.
1945 /// http://tizen.org/privilege/ime
1947 /// <exception cref="InvalidOperationException">
1948 /// This can occur due to the following reasons:
1949 /// 1) The application does not have the privilege to call this function.
1950 /// 2) Operation failed.
1952 /// <since_tizen> 4 </since_tizen>
1953 [EditorBrowsable(EditorBrowsableState.Never)]
1954 public static void Create()
1956 ErrorCode error = ImeInitialize();
1957 Log.Info(LogTag, "ImeInitialize result : " + error);
1958 if (error != ErrorCode.None)
1960 Log.Error(LogTag, "ImeInitialize Failed with error " + error);
1961 throw InputMethodExceptionFactory.CreateException(error);
1964 error = ImePrepare();
1965 Log.Info(LogTag, "ImePrepare result : " + error);
1966 if (error != ErrorCode.None)
1968 Log.Error(LogTag, "ImePrepare Failed with error " + error);
1969 throw InputMethodExceptionFactory.CreateException(error);
1974 /// This API requests the InputMethodEditor to finalize.
1977 /// http://tizen.org/privilege/ime
1979 /// <exception cref="InvalidOperationException">
1980 /// This can occur due to the following reasons:
1981 /// 1) The application does not have the privilege to call this function.
1982 /// 2) Operation failed.
1984 /// <since_tizen> 4 </since_tizen>
1985 [EditorBrowsable(EditorBrowsableState.Never)]
1986 public static void Destroy()
1988 ErrorCode error = ImeFinalize();
1989 Log.Info(LogTag, "ImeFinalize result : " + error);
1990 if (error != ErrorCode.None)
1992 Log.Error(LogTag, "ImeFinalize Failed with error " + error);
1993 throw InputMethodExceptionFactory.CreateException(error);
1998 /// Sets the floating mode to on or off.
2001 /// http://tizen.org/privilege/ime
2003 /// <param name="floatingMode"><c>true</c> to set the floating mode to on and <c>false</c> to set it to off.</param>
2004 /// <exception cref="InvalidOperationException">
2005 /// This can occur due to the following reasons:
2006 /// 1) The application does not have the privilege to call this function.
2007 /// 2) The IME main loop has not started yet.
2009 /// <since_tizen> 5 </since_tizen>
2010 public static void SetFloatingMode(bool floatingMode)
2012 ErrorCode error = ImeSetFloatingMode(floatingMode);
2013 if (error != ErrorCode.None)
2015 Log.Error(LogTag, "SetFloatingMode Failed with error " + error);
2016 throw InputMethodExceptionFactory.CreateException(error);
2021 /// Allows the floating input panel window to move along with the mouse pointer when the mouse is pressed.
2024 /// http://tizen.org/privilege/ime
2027 /// This function can be used in floating mode. If the floating mode is deactivated, calling this function has no effect.
2029 /// <exception cref="InvalidOperationException">
2030 /// This can occur due to the following reasons:
2031 /// 1) The application does not have the privilege to call this function.
2032 /// 2) The IME main loop has not started yet.
2034 /// <since_tizen> 5 </since_tizen>
2035 public static void SetFloatingDragStart()
2037 ErrorCode error = ImeSetFloatingDragStart();
2038 if (error != ErrorCode.None)
2040 Log.Error(LogTag, "SetFloatingDragStart Failed with error " + error);
2041 throw InputMethodExceptionFactory.CreateException(error);
2046 /// Does not allow the movement of the floating input panel window with the mouse pointer when the mouse is pressed.
2049 /// http://tizen.org/privilege/ime
2052 /// This function can be used in floating mode. If the floating mode is deactivated, calling this function has no effect.
2054 /// <exception cref="InvalidOperationException">
2055 /// This can occur due to the following reasons:
2056 /// 1) The application does not have the privilege to call this function.
2057 /// 2) The IME main loop has not started yet.
2059 /// <since_tizen> 5 </since_tizen>
2060 public static void SetFloatingDragEnd()
2062 ErrorCode error = ImeSetFloatingDragEnd();
2063 if (error != ErrorCode.None)
2065 Log.Error(LogTag, "SetFloatingDragEnd Failed with error " + error);
2066 throw InputMethodExceptionFactory.CreateException(error);
2071 /// Notifies the changed language of the input panel to the the associated text input UI control.
2074 /// http://tizen.org/privilege/ime
2077 /// LanguageRequestedCallback is raised after this API is called when the App requests changed language information.
2079 /// <exception cref="InvalidOperationException">
2080 /// This can occur due to the following reasons:
2081 /// 1) The application does not have the privilege to call this function.
2082 /// 2) The IME main loop has not started yet.
2084 /// <since_tizen> 6 </since_tizen>
2085 public static void SendLanguageUpdated()
2087 ErrorCode error = ImeUpdateInputPanelEvent(ImeEventType.Language, 0);
2088 if (error != ErrorCode.None)
2090 Log.Error(LogTag, "SendLanguageUpdated Failed with error " + error);
2091 throw InputMethodExceptionFactory.CreateException(error);
2096 /// Sends the changed shift mode of the input panel to the the associated text input UI control.
2099 /// http://tizen.org/privilege/ime
2101 /// <param name="enable"><c>true</c> if shift button is clicked, otherwise <c>false</c>.</param>
2102 /// <exception cref="InvalidOperationException">
2103 /// This can occur due to the following reasons:
2104 /// 1) The application does not have the privilege to call this function.
2105 /// 2) The IME main loop has not started yet.
2107 /// <since_tizen> 6 </since_tizen>
2108 public static void SendShiftModeUpdated(bool enable)
2110 ErrorCode error = ImeUpdateInputPanelEvent(ImeEventType.ShiftMode, enable ? (uint)ImeShiftMode.On : (uint)ImeShiftMode.Off);
2111 if (error != ErrorCode.None)
2113 Log.Error(LogTag, "SendInputPanelEvent Failed with error " + error);
2114 throw InputMethodExceptionFactory.CreateException(error);
2119 /// Notifies the changed geometry of input panel window to the associated text input UI control.
2122 /// http://tizen.org/privilege/ime
2124 /// <exception cref="InvalidOperationException">
2125 /// This can occur due to the following reasons:
2126 /// 1) The application does not have the privilege to call this function.
2127 /// 2) The IME main loop has not started yet.
2129 /// <since_tizen> 6 </since_tizen>
2130 public static void SendCustomGeometryUpdated()
2132 ErrorCode error = ImeUpdateInputPanelEvent(ImeEventType.Geometry, 0);
2133 if (error != ErrorCode.None)
2135 Log.Error(LogTag, "SendCustomGeometryUpdated Failed with error " + error);
2136 throw InputMethodExceptionFactory.CreateException(error);
2141 /// Gets the selected text synchronously.
2144 /// http://tizen.org/privilege/ime
2146 /// <returns>The selected text.</returns>
2147 /// <exception cref="InvalidOperationException">
2148 /// This can occur due to the following reasons:
2149 /// 1) The application does not have the privilege to call this function.
2150 /// 2) The IME main loop has not started yet.
2152 /// <since_tizen> 6 </since_tizen>
2153 public static string GetSelectedText()
2156 ErrorCode error = ImeGetSelectedText(out txt);
2157 if (error != ErrorCode.None)
2159 Log.Error(LogTag, "GetSelectedText Failed with error " + error);
2160 throw InputMethodExceptionFactory.CreateException(error);
2162 return Marshal.PtrToStringAnsi(txt);
2166 /// Called to set the prediction hint string to deliver to the input panel.
2168 /// <since_tizen> 6 </since_tizen>
2169 public static event EventHandler<PredictionHintUpdatedEventArgs> PredictionHintUpdated
2173 if (_imePredictionHintSetDelegate == null)
2175 _imePredictionHintSetDelegate = (IntPtr predictionHint, IntPtr userData) =>
2177 PredictionHintUpdatedEventArgs args = new PredictionHintUpdatedEventArgs(Marshal.PtrToStringAnsi(predictionHint));
2178 _predictionHintUpdated?.Invoke(null, args);
2180 ErrorCode error = ImeEventSetPredictionHintSetCb(_imePredictionHintSetDelegate, IntPtr.Zero);
2181 if (error != ErrorCode.None)
2183 Log.Error(LogTag, "Add PredictionHintUpdated Failed with error " + error);
2186 _predictionHintUpdated += value;
2190 _predictionHintUpdated -= value;
2195 /// Called to set the prediction hint key and value to deliver to the input panel.
2197 /// <since_tizen> 6 </since_tizen>
2198 public static event EventHandler<PredictionHintDataUpdatedEventArgs> PredictionHintDataUpdated
2202 if (_imePredictionHintDataSetDelegate == null)
2204 _imePredictionHintDataSetDelegate = (IntPtr key, IntPtr keyValue, IntPtr userData) =>
2206 PredictionHintDataUpdatedEventArgs args = new PredictionHintDataUpdatedEventArgs(Marshal.PtrToStringAnsi(key), Marshal.PtrToStringAnsi(keyValue));
2207 _predictionHintDataUpdated?.Invoke(null, args);
2210 ErrorCode error = ImeEventSetPredictionHintDataSetCb(_imePredictionHintDataSetDelegate, IntPtr.Zero);
2211 if (error != ErrorCode.None)
2213 Log.Error(LogTag, "Add PredictionHintDataUpdated Failed with error " + error);
2216 _predictionHintDataUpdated += value;
2220 _predictionHintDataUpdated -= value;
2225 /// Called when an associated text input UI control requests the text entry to set the MIME type.
2227 /// <since_tizen> 6 </since_tizen>
2228 public static event EventHandler<MimeTypeUpdateRequestedEventArgs> MimeTypeUpdateRequested
2232 if (_imeMimeTypeSetRequestDelegate == null)
2234 _imeMimeTypeSetRequestDelegate = (IntPtr mimeType, IntPtr userData) =>
2236 MimeTypeUpdateRequestedEventArgs args = new MimeTypeUpdateRequestedEventArgs(Marshal.PtrToStringAnsi(mimeType));
2237 _mimeTypeUpdateRequested?.Invoke(null, args);
2239 ErrorCode error = ImeEventSetMimeTypeSetRequestCb(_imeMimeTypeSetRequestDelegate, IntPtr.Zero);
2240 if (error != ErrorCode.None)
2242 Log.Error(LogTag, "Add MimeTypeUpdateRequested Failed with error " + error);
2245 _mimeTypeUpdateRequested += value;
2249 _mimeTypeUpdateRequested -= value;
2254 /// Sends a private command to the associated text input UI control.
2257 /// http://tizen.org/privilege/ime
2259 /// <param name="command">The UTF-8 string to be sent.</param>
2260 /// <exception cref="InvalidOperationException">
2261 /// This can occur due to the following reasons:
2262 /// 1) The application does not have the privilege to call this function.
2263 /// 2) The IME main loop has not started yet.
2264 /// 3) Invalid parameter.
2266 /// <since_tizen> 6 </since_tizen>
2267 public static void SendPrivateCommand(string command)
2269 ErrorCode error = ImeSendPrivateCommand(command);
2270 if (error != ErrorCode.None)
2272 Log.Error(LogTag, "SendPrivateCommand Failed with error " + error);
2273 throw InputMethodExceptionFactory.CreateException(error);
2278 /// Commits contents such as image to the associated text input UI control.
2281 /// http://tizen.org/privilege/ime
2283 /// <param name="content">The content URI to be sent.</param>
2284 /// <param name="description">The content description.</param>
2285 /// <param name="mimeType">The MIME type received from the MimeTypeSetRequest</param>
2286 /// <exception cref="InvalidOperationException">
2287 /// This can occur due to the following reasons:
2288 /// 1) The application does not have the privilege to call this function.
2289 /// 2) The IME main loop has not started yet.
2290 /// 3) Invalid parameter.
2292 /// <since_tizen> 6 </since_tizen>
2293 public static void CommitContent(string content, string description, string mimeType)
2295 ErrorCode error = ImeCommitContent(content, description, mimeType);
2296 if (error != ErrorCode.None)
2298 Log.Error(LogTag, "CommitContent Failed with error " + error);
2299 throw InputMethodExceptionFactory.CreateException(error);