/// <since_tizen> 4 </since_tizen>
public static class InputMethodEditor
{
- private static Object thisLock = new Object();
private static ImeCallbackStructGCHandle _imeCallbackStructGCHandle = new ImeCallbackStructGCHandle();
private static event EventHandler<FocusedInEventArgs> _focusIn;
private static ImeFocusedInCb _imeFocusedInDelegate;
private static OutArrayAction<byte> _imDataRequestedDelegate;
private static ImeGeometryRequestedCb _imeGeometryRequestedDelegate;
private static OutAction<Rect> _geometryRequestedDelegate;
+ private static ImeProcessKeyEventWithKeycodeCb _imeProcessKeyWithKeycodeDelegate;
+ private static BoolAction<uint, KeyCode, KeyMask, InputMethodDeviceInformation> _processKeyWithKeycodeDelagate;
+ private static event EventHandler<InputHintSetEventArgs> _inputHintSet;
+ private static ImeInputHintSetCb _imeInputHintSetDelegate;
private static Action _userCreate;
private static Action _userTerminate;
private static Action<ContextId, InputMethodContext> _userShow;
public delegate bool BoolAction<T, T1, T2>(T a, T1 b, T2 c);
/// <summary>
+ /// An action with 4 input parameters returning a bool.
+ /// </summary>
+ /// <typeparam name="T">Generic type for parameter 1.</typeparam>
+ /// <typeparam name="T1">Generic type for parameter 2.</typeparam>
+ /// <typeparam name="T2">Generic type for parameter 3.</typeparam>
+ /// <typeparam name="T3">Generic type for parameter 4.</typeparam>
+ /// <param name="a">The input parameter 1.</param>
+ /// <param name="b">The input parameter 2.</param>
+ /// <param name="c">The input parameter 3.</param>
+ /// <param name="d">The input parameter 4.</param>
+ /// <returns></returns>
+ /// <since_tizen> 10 </since_tizen>
+ public delegate bool BoolAction<T, T1, T2, T3>(T a, T1 b, T2 c, T3 d);
+
+ /// <summary>
/// Called when an associated text input UI control has focus.
/// </summary>
/// <since_tizen> 4 </since_tizen>
{
add
{
- lock (thisLock)
+ _imeFocusedInDelegate = (int contextId, IntPtr userData) =>
{
- _imeFocusedInDelegate = (int contextId, IntPtr userData) =>
- {
- FocusedInEventArgs args = new FocusedInEventArgs(contextId);
- _focusIn?.Invoke(null, args);
- };
- ErrorCode error = ImeEventSetFocusedInCb(_imeFocusedInDelegate, IntPtr.Zero);
- if (error != ErrorCode.None)
- {
- Log.Error(LogTag, "Add FocusedIn Failed with error " + error);
- }
- else
- {
- _focusIn += value;
- }
+ FocusedInEventArgs args = new FocusedInEventArgs(contextId);
+ _focusIn?.Invoke(null, args);
+ };
+ ErrorCode error = ImeEventSetFocusedInCb(_imeFocusedInDelegate, IntPtr.Zero);
+ if (error != ErrorCode.None)
+ {
+ Log.Error(LogTag, "Add FocusedIn Failed with error " + error);
+ }
+ else
+ {
+ _focusIn += value;
}
}
remove
{
- lock (thisLock)
- {
- _focusIn -= value;
- }
+ _focusIn -= value;
}
}
{
add
{
- lock (thisLock)
+ _imeFocusedOutDelegate = (int contextId, IntPtr userData) =>
{
- _imeFocusedOutDelegate = (int contextId, IntPtr userData) =>
- {
- FocusedOutEventArgs args = new FocusedOutEventArgs(contextId);
- _focusOut?.Invoke(null, args);
- };
- ErrorCode error = ImeEventSetFocusedOutCb(_imeFocusedOutDelegate, IntPtr.Zero);
- if (error != ErrorCode.None)
- {
- Log.Error(LogTag, "Add FocusedOut Failed with error " + error);
- }
- else
- {
- _focusOut += value;
- }
+ FocusedOutEventArgs args = new FocusedOutEventArgs(contextId);
+ _focusOut?.Invoke(null, args);
+ };
+ ErrorCode error = ImeEventSetFocusedOutCb(_imeFocusedOutDelegate, IntPtr.Zero);
+ if (error != ErrorCode.None)
+ {
+ Log.Error(LogTag, "Add FocusedOut Failed with error " + error);
+ }
+ else
+ {
+ _focusOut += value;
}
}
remove
{
- lock (thisLock)
- {
- _focusOut -= value;
- }
+ _focusOut -= value;
}
}
{
add
{
- lock (thisLock)
+ _imeSurroundingTextUpdatedDelegate = (int contextId, IntPtr text, int cursorPos, IntPtr userData) =>
{
- _imeSurroundingTextUpdatedDelegate = (int contextId, IntPtr text, int cursorPos, IntPtr userData) =>
- {
- SurroundingTextUpdatedEventArgs args = new SurroundingTextUpdatedEventArgs(contextId, Marshal.PtrToStringAnsi(text), cursorPos);
- _surroundingTextUpdated?.Invoke(null, args);
- };
- ErrorCode error = ImeEventSetSurroundingTextUpdatedCb(_imeSurroundingTextUpdatedDelegate, IntPtr.Zero);
- if (error != ErrorCode.None)
- {
- Log.Error(LogTag, "Add SurroundingTextUpdated Failed with error " + error);
- }
- else
- {
- _surroundingTextUpdated += value;
- }
+ SurroundingTextUpdatedEventArgs args = new SurroundingTextUpdatedEventArgs(contextId, Marshal.PtrToStringAnsi(text), cursorPos);
+ _surroundingTextUpdated?.Invoke(null, args);
+ };
+ ErrorCode error = ImeEventSetSurroundingTextUpdatedCb(_imeSurroundingTextUpdatedDelegate, IntPtr.Zero);
+ if (error != ErrorCode.None)
+ {
+ Log.Error(LogTag, "Add SurroundingTextUpdated Failed with error " + error);
+ }
+ else
+ {
+ _surroundingTextUpdated += value;
}
}
remove
{
- lock (thisLock)
- {
- _surroundingTextUpdated -= value;
- }
+ _surroundingTextUpdated -= value;
}
}
{
add
{
- lock (thisLock)
+ _imeInputContextResetDelegate = (IntPtr userData) =>
{
- _imeInputContextResetDelegate = (IntPtr userData) =>
- {
- _inputContextReset?.Invoke(null, EventArgs.Empty);
- };
- ErrorCode error = ImeEventSetInputContextResetCb(_imeInputContextResetDelegate, IntPtr.Zero);
- if (error != ErrorCode.None)
- {
- Log.Error(LogTag, "Add InputContextReset Failed with error " + error);
- }
- else
- {
- _inputContextReset += value;
- }
+ _inputContextReset?.Invoke(null, EventArgs.Empty);
+ };
+ ErrorCode error = ImeEventSetInputContextResetCb(_imeInputContextResetDelegate, IntPtr.Zero);
+ if (error != ErrorCode.None)
+ {
+ Log.Error(LogTag, "Add InputContextReset Failed with error " + error);
+ }
+ else
+ {
+ _inputContextReset += value;
}
}
remove
{
- lock (thisLock)
- {
- _inputContextReset -= value;
- }
+ _inputContextReset -= value;
}
}
{
add
{
- lock (thisLock)
+ _imeCursorPositionUpdatedDelegate = (int cursorPos, IntPtr userData) =>
{
- _imeCursorPositionUpdatedDelegate = (int cursorPos, IntPtr userData) =>
- {
- CursorPositionUpdatedEventArgs args = new CursorPositionUpdatedEventArgs(cursorPos);
- _cursorPositionUpdated?.Invoke(null, args);
- };
- ErrorCode error = ImeEventSetCursorPositionUpdatedCb(_imeCursorPositionUpdatedDelegate, IntPtr.Zero);
- if (error != ErrorCode.None)
- {
- Log.Error(LogTag, "Add CursorPositionUpdated Failed with error " + error);
- }
- else
- {
- _cursorPositionUpdated += value;
- }
+ CursorPositionUpdatedEventArgs args = new CursorPositionUpdatedEventArgs(cursorPos);
+ _cursorPositionUpdated?.Invoke(null, args);
+ };
+ ErrorCode error = ImeEventSetCursorPositionUpdatedCb(_imeCursorPositionUpdatedDelegate, IntPtr.Zero);
+ if (error != ErrorCode.None)
+ {
+ Log.Error(LogTag, "Add CursorPositionUpdated Failed with error " + error);
+ }
+ else
+ {
+ _cursorPositionUpdated += value;
}
}
remove
{
- lock (thisLock)
- {
- _cursorPositionUpdated -= value;
- }
+ _cursorPositionUpdated -= value;
}
}
{
add
{
- lock (thisLock)
+ _imeLanguageSetDelegate = (InputPanelLanguage language, IntPtr userData) =>
{
- _imeLanguageSetDelegate = (InputPanelLanguage language, IntPtr userData) =>
- {
- LanguageSetEventArgs args = new LanguageSetEventArgs(language);
- _langaugeSet?.Invoke(null, args);
- };
- ErrorCode error = ImeEventSetLanguageSetCb(_imeLanguageSetDelegate, IntPtr.Zero);
- if (error != ErrorCode.None)
- {
- Log.Error(LogTag, "Add LanguageSet Failed with error " + error);
- }
- else
- {
- _langaugeSet += value;
- }
+ LanguageSetEventArgs args = new LanguageSetEventArgs(language);
+ _langaugeSet?.Invoke(null, args);
+ };
+ ErrorCode error = ImeEventSetLanguageSetCb(_imeLanguageSetDelegate, IntPtr.Zero);
+ if (error != ErrorCode.None)
+ {
+ Log.Error(LogTag, "Add LanguageSet Failed with error " + error);
+ }
+ else
+ {
+ _langaugeSet += value;
}
}
remove
{
- lock (thisLock)
- {
- _langaugeSet -= value;
- }
+ _langaugeSet -= value;
}
}
{
add
{
- lock (thisLock)
+ _imeDataSetDelegate = (IntPtr data, uint dataLength, IntPtr userData) =>
{
- _imeDataSetDelegate = (IntPtr data, uint dataLength, IntPtr userData) =>
- {
- byte[] destination = new byte[dataLength];
- Marshal.Copy(data, destination, 0, (int)dataLength);
- SetDataEventArgs args = new SetDataEventArgs(destination, dataLength);
- _imDataSet?.Invoke(null, args);
- };
- ErrorCode error = ImeEventSetImdataSetCb(_imeDataSetDelegate, IntPtr.Zero);
- if (error != ErrorCode.None)
- {
- Log.Error(LogTag, "Add DataSet Failed with error " + error);
- }
- else
- {
- _imDataSet += value;
- }
+ byte[] destination = new byte[dataLength];
+ Marshal.Copy(data, destination, 0, (int)dataLength);
+ SetDataEventArgs args = new SetDataEventArgs(destination, dataLength);
+ _imDataSet?.Invoke(null, args);
+ };
+ ErrorCode error = ImeEventSetImdataSetCb(_imeDataSetDelegate, IntPtr.Zero);
+ if (error != ErrorCode.None)
+ {
+ Log.Error(LogTag, "Add DataSet Failed with error " + error);
+ }
+ else
+ {
+ _imDataSet += value;
}
}
remove
{
- lock (thisLock)
- {
- _imDataSet -= value;
- }
+ _imDataSet -= value;
}
}
{
add
{
- lock (thisLock)
+ _imeLayoutSetDelegate = (InputPanelLayout layout, IntPtr userData) =>
{
- _imeLayoutSetDelegate = (InputPanelLayout layout, IntPtr userData) =>
- {
- LayoutSetEventArgs args = new LayoutSetEventArgs(layout);
- _layoutSet?.Invoke(null, args);
- };
- ErrorCode error = ImeEventSetLayoutSetCb(_imeLayoutSetDelegate, IntPtr.Zero);
- if (error != ErrorCode.None)
- {
- Log.Error(LogTag, "Add LayoutSet Failed with error " + error);
- }
- else
- {
- _layoutSet += value;
- }
+ LayoutSetEventArgs args = new LayoutSetEventArgs(layout);
+ _layoutSet?.Invoke(null, args);
+ };
+ ErrorCode error = ImeEventSetLayoutSetCb(_imeLayoutSetDelegate, IntPtr.Zero);
+ if (error != ErrorCode.None)
+ {
+ Log.Error(LogTag, "Add LayoutSet Failed with error " + error);
+ }
+ else
+ {
+ _layoutSet += value;
}
}
remove
{
- lock (thisLock)
- {
- _layoutSet -= value;
- }
+ _layoutSet -= value;
}
}
{
add
{
- lock (thisLock)
+ _imeReturnKeySetDelegate = (InputPanelReturnKey type, IntPtr userData) =>
{
- _imeReturnKeySetDelegate = (InputPanelReturnKey type, IntPtr userData) =>
- {
- ReturnKeySetEventArgs args = new ReturnKeySetEventArgs(type);
- _returnKeyTypeSet?.Invoke(null, args);
- };
- ErrorCode error = ImeEventSetReturnKeySetCb(_imeReturnKeySetDelegate, IntPtr.Zero);
- if (error != ErrorCode.None)
- {
- Log.Error(LogTag, "Add ReturnKeySet Failed with error " + error);
- }
- else
- {
- _returnKeyTypeSet += value;
- }
+ ReturnKeySetEventArgs args = new ReturnKeySetEventArgs(type);
+ _returnKeyTypeSet?.Invoke(null, args);
+ };
+ ErrorCode error = ImeEventSetReturnKeySetCb(_imeReturnKeySetDelegate, IntPtr.Zero);
+ if (error != ErrorCode.None)
+ {
+ Log.Error(LogTag, "Add ReturnKeySet Failed with error " + error);
+ }
+ else
+ {
+ _returnKeyTypeSet += value;
}
}
remove
{
- lock (thisLock)
- {
- _returnKeyTypeSet -= value;
- }
+ _returnKeyTypeSet -= value;
}
}
{
add
{
- lock (thisLock)
+ _imeReturnKeyStateSetDelegate = (bool state, IntPtr userData) =>
{
- _imeReturnKeyStateSetDelegate = (bool state, IntPtr userData) =>
- {
- ReturnKeyStateSetEventArgs args = new ReturnKeyStateSetEventArgs(state);
- _returnKeyStateSet?.Invoke(null, args);
- };
- ErrorCode error = ImeEventSetReturnKeyStateSetCb(_imeReturnKeyStateSetDelegate, IntPtr.Zero);
- if (error != ErrorCode.None)
- {
- Log.Error(LogTag, "Add ReturnKeyStateSet Failed with error " + error);
- }
- else
- {
- _returnKeyStateSet += value;
- }
+ ReturnKeyStateSetEventArgs args = new ReturnKeyStateSetEventArgs(state);
+ _returnKeyStateSet?.Invoke(null, args);
+ };
+ ErrorCode error = ImeEventSetReturnKeyStateSetCb(_imeReturnKeyStateSetDelegate, IntPtr.Zero);
+ if (error != ErrorCode.None)
+ {
+ Log.Error(LogTag, "Add ReturnKeyStateSet Failed with error " + error);
+ }
+ else
+ {
+ _returnKeyStateSet += value;
}
}
remove
{
- lock (thisLock)
- {
- _returnKeyStateSet -= value;
- }
+ _returnKeyStateSet -= value;
}
}
{
add
{
- lock (thisLock)
+ _imeDisplayLanguageChangedDelegate = (IntPtr language, IntPtr userData) =>
{
- _imeDisplayLanguageChangedDelegate = (IntPtr language, IntPtr userData) =>
- {
- DisplayLanguageChangedEventArgs args = new DisplayLanguageChangedEventArgs(Marshal.PtrToStringAnsi(language));
- _displayLanguageChanged?.Invoke(null, args);
- };
- ErrorCode error = ImeEventSetDisplayLanguageChangedCb(_imeDisplayLanguageChangedDelegate, IntPtr.Zero);
- if (error != ErrorCode.None)
- {
- Log.Error(LogTag, "Add DisplayLanguageChanged Failed with error " + error);
- }
- else
- {
- _displayLanguageChanged += value;
- }
+ DisplayLanguageChangedEventArgs args = new DisplayLanguageChangedEventArgs(Marshal.PtrToStringAnsi(language));
+ _displayLanguageChanged?.Invoke(null, args);
+ };
+ ErrorCode error = ImeEventSetDisplayLanguageChangedCb(_imeDisplayLanguageChangedDelegate, IntPtr.Zero);
+ if (error != ErrorCode.None)
+ {
+ Log.Error(LogTag, "Add DisplayLanguageChanged Failed with error " + error);
+ }
+ else
+ {
+ _displayLanguageChanged += value;
}
}
remove
{
- lock (thisLock)
- {
- _displayLanguageChanged -= value;
- }
+ _displayLanguageChanged -= value;
}
}
{
add
{
- lock (thisLock)
+ _imeRotationChangedDelegate = (int degree, IntPtr userData) =>
{
- _imeRotationChangedDelegate = (int degree, IntPtr userData) =>
- {
- RotationChangedEventArgs args = new RotationChangedEventArgs(degree);
- _rotationDegreeChanged?.Invoke(null, args);
- };
- ErrorCode error = ImeEventSetRotationChangedCb(_imeRotationChangedDelegate, IntPtr.Zero);
- if (error != ErrorCode.None)
- {
- Log.Error(LogTag, "Add RotationChanged Failed with error " + error);
- }
- else
- {
- _rotationDegreeChanged += value;
- }
+ RotationChangedEventArgs args = new RotationChangedEventArgs(degree);
+ _rotationDegreeChanged?.Invoke(null, args);
+ };
+ ErrorCode error = ImeEventSetRotationChangedCb(_imeRotationChangedDelegate, IntPtr.Zero);
+ if (error != ErrorCode.None)
+ {
+ Log.Error(LogTag, "Add RotationChanged Failed with error " + error);
+ }
+ else
+ {
+ _rotationDegreeChanged += value;
}
}
remove
{
- lock (thisLock)
- {
- _rotationDegreeChanged -= value;
- }
+ _rotationDegreeChanged -= value;
}
}
{
add
{
- lock (thisLock)
+ _imeAccessibilityStateChangedDelegate = (bool state, IntPtr userData) =>
{
- _imeAccessibilityStateChangedDelegate = (bool state, IntPtr userData) =>
- {
- AccessibilityStateChangedEventArgs args = new AccessibilityStateChangedEventArgs(state);
- _accessibilityStateChanged?.Invoke(null, args);
- };
- ErrorCode error = ImeEventSetAccessibilityStateChangedCb(_imeAccessibilityStateChangedDelegate, IntPtr.Zero);
- if (error != ErrorCode.None)
- {
- Log.Error(LogTag, "Add AccessibilityStateChanged Failed with error " + error);
- }
- else
- {
- _accessibilityStateChanged += value;
- }
+ AccessibilityStateChangedEventArgs args = new AccessibilityStateChangedEventArgs(state);
+ _accessibilityStateChanged?.Invoke(null, args);
+ };
+ ErrorCode error = ImeEventSetAccessibilityStateChangedCb(_imeAccessibilityStateChangedDelegate, IntPtr.Zero);
+ if (error != ErrorCode.None)
+ {
+ Log.Error(LogTag, "Add AccessibilityStateChanged Failed with error " + error);
+ }
+ else
+ {
+ _accessibilityStateChanged += value;
}
}
remove
{
- lock (thisLock)
- {
- _accessibilityStateChanged -= value;
- }
+ _accessibilityStateChanged -= value;
}
}
{
_imeLanguageRequestedDelegate = (IntPtr userData, out IntPtr langCode) =>
{
- string langauage;
- _languageRequestedDelegate(out langauage);
- langCode = (IntPtr)Marshal.StringToHGlobalAnsi(langauage);
+ string language;
+ _languageRequestedDelegate(out language);
+ langCode = (IntPtr)Marshal.StringToHGlobalAnsi(language);
};
ErrorCode error = ImeEventSetLanguageRequestedCallbackCb(_imeLanguageRequestedDelegate, IntPtr.Zero);
if (error != ErrorCode.None)
/// This is called when the IME application is hidden.
/// It provides the context ID.
/// </param>
- /// <exception cref="InvalidOperationException">
- /// This can occur due to the following reasons:
- /// 1) The application does not have the privilege to call this function.
- /// 2) Operation failed.
- /// </exception>
+ /// <exception cref="UnauthorizedAccessException">This exception can be due to permission denied.</exception>
+ /// <exception cref="InvalidOperationException">This exception can be due to operation failed.</exception>
/// <since_tizen> 4 </since_tizen>
public static void Run(Action create, Action terminate, Action<ContextId, InputMethodContext> show, Action<ContextId> hide)
{
/// <param name="keyCode">The key code to be sent.</param>
/// <param name="keyMask">The modifier key mask.</param>
/// <param name="forwardKey">The flag to send the key event directly to the edit field.</param>
- /// <exception cref="InvalidOperationException">
- /// This can occur due to the following reasons:
- /// 1) The application does not have the privilege to call this function.
- /// 2) The IME main loop has not started yet.
- /// </exception>
+ /// <exception cref="UnauthorizedAccessException">This exception can be due to permission denied.</exception>
+ /// <exception cref="InvalidOperationException">The IME main loop has not started yet.</exception>
/// <since_tizen> 4 </since_tizen>
public static void SendKeyEvent(KeyCode keyCode, KeyMask keyMask, bool forwardKey = false)
{
/// http://tizen.org/privilege/ime
/// </privilege>
/// <param name="str">The string to be committed.</param>
- /// <exception cref="InvalidOperationException">
- /// This can occur due to the following reasons:
- /// 1) The application does not have the privilege to call this function.
- /// 2) The IME main loop has not started yet.
- /// </exception>
+ /// <exception cref="UnauthorizedAccessException">This exception can be due to permission denied.</exception>
+ /// <exception cref="InvalidOperationException">The IME main loop has not started yet.</exception>
/// <since_tizen> 4 </since_tizen>
public static void CommitString(string str)
{
/// <privilege>
/// http://tizen.org/privilege/ime
/// </privilege>
- /// <exception cref="InvalidOperationException">
- /// This can occur due to the following reasons:
- /// 1) The application does not have the privilege to call this function.
- /// 2) The IME main loop has not started yet.
- /// </exception>
+ /// <exception cref="UnauthorizedAccessException">This exception can be due to permission denied.</exception>
+ /// <exception cref="InvalidOperationException">The IME main loop has not started yet.</exception>
/// <since_tizen> 4 </since_tizen>
public static void ShowPreEditString()
{
/// <privilege>
/// http://tizen.org/privilege/ime
/// </privilege>
- /// <exception cref="InvalidOperationException">
- /// This can occur due to the following reasons:
- /// 1) The application does not have the privilege to call this function.
- /// 2) The IME main loop has not started yet.
- /// </exception>
+ /// <exception cref="UnauthorizedAccessException">This exception can be due to permission denied.</exception>
+ /// <exception cref="InvalidOperationException">The IME main loop has not started yet.</exception>
/// <since_tizen> 4 </since_tizen>
public static void HidePreEditString()
{
/// The list which has ime_preedit_attribute lists, strings can be composed of multiple string attributes: underline, highlight color, and reversal color.
/// The attrs list can be empty if no attributes to set.
/// </param>
- /// <exception cref="InvalidOperationException">
- /// This can occur due to the following reasons:
- /// 1) The application does not have the privilege to call this function.
- /// 2) The IME main loop has not started yet.
- /// 3) Invalid parameter.
- /// </exception>
+ /// <exception cref="UnauthorizedAccessException">This exception can be due to permission denied.</exception>
+ /// <exception cref="InvalidOperationException">The IME main loop has not started yet.</exception>
/// <since_tizen> 4 </since_tizen>
public static void UpdatePreEditString(string str, IEnumerable<PreEditAttribute> attrs)
{
IntPtr einaList = IntPtr.Zero;
- List<GCHandle> attributeHandleList = new List<GCHandle>();
foreach (PreEditAttribute attribute in attrs)
{
+ IntPtr attr = IntPtr.Zero;
ImePreEditAttributeStruct imePreEditAttribute = new ImePreEditAttributeStruct();
imePreEditAttribute.start = attribute.Start;
imePreEditAttribute.length = attribute.Length;
imePreEditAttribute.type = (int)attribute.Type;
imePreEditAttribute.value = attribute.Value;
- GCHandle attributeHandle = GCHandle.Alloc(imePreEditAttribute, GCHandleType.Pinned);
- attributeHandleList.Add(attributeHandle);
- einaList = Interop.EinaList.EinaListAppend(einaList, attributeHandle.AddrOfPinnedObject());
+ attr = Marshal.AllocHGlobal(Marshal.SizeOf(imePreEditAttribute));
+ Marshal.WriteIntPtr(attr, IntPtr.Zero);
+ Marshal.StructureToPtr(imePreEditAttribute, attr, false);
+ einaList = Interop.EinaList.EinaListAppend(einaList, attr);
}
ErrorCode error = ImeUpdatePreeditString(str, einaList);
- foreach (GCHandle handle in attributeHandleList)
- {
- handle.Free();
- }
if (error != ErrorCode.None)
{
Log.Error(LogTag, "UpdatePreEditString Failed with error " + error);
/// </privilege>
/// <param name="maxLenBefore">The maximum length of the string to be retrieved before the cursor, -1 means unlimited.</param>
/// <param name="maxLenAfter">The maximum length of the string to be retrieved after the cursor, -1 means unlimited.</param>
+ /// <exception cref="UnauthorizedAccessException">This exception can be due to permission denied.</exception>
/// <exception cref="InvalidOperationException">
/// This can occur due to the following reasons:
- /// 1) The application does not have the privilege to call this function.
- /// 2) The IME main loop has not started yet.
+ /// 1) The IME main loop has not started yet.
+ /// 2) The necessary event is not set.
/// </exception>
/// <postcondition>
/// The requested surrounding text can be received using the SurroundingTextUpdated event, only if it is set.
/// </privilege>
/// <param name="offset">The offset value from the cursor position.</param>
/// <param name="len">The length of the text to delete.</param>
- /// <exception cref="InvalidOperationException">
- /// This can occur due to the following reasons:
- /// 1) The application does not have the privilege to call this function.
- /// 2) The IME main loop has not started yet.
- /// 3) Invalid parameter.
- /// </exception>
+ /// <exception cref="ArgumentException">This exception can be due to an invalid parameter.</exception>
+ /// <exception cref="UnauthorizedAccessException">This exception can be due to permission denied.</exception>
+ /// <exception cref="InvalidOperationException">The IME main loop has not started yet.</exception>
/// <since_tizen> 4 </since_tizen>
public static void DeleteSurroundingText(int offset, int len)
{
/// <param name="maxLenAfter">The maximum length of the string to be retrieved after the cursor, -1 means unlimited.</param>
/// <param name="text">The surrounding text.</param>
/// <param name="cursorPosition">The cursor position.</param>
- /// <exception cref="InvalidOperationException">
- /// This can occur due to the following reasons:
- /// 1) The application does not have the privilege to call this function.
- /// 2) The IME main loop has not started yet.
- /// 3) Invalid parameter.
- /// 4) Failed to obtain text due to out of memory.
- /// </exception>
+ /// <exception cref="OutOfMemoryException">This exception can be due to out of memory.</exception>
+ /// <exception cref="UnauthorizedAccessException">This exception can be due to permission denied.</exception>
+ /// <exception cref="InvalidOperationException">The IME main loop has not started yet.</exception>
/// <since_tizen> 4 </since_tizen>
public static void GetSurroundingText(int maxLenBefore, int maxLenAfter, out string text, out int cursorPosition)
{
/// </privilege>
/// <param name="start">The start cursor position in text (in characters not bytes).</param>
/// <param name="end">The end cursor position in text (in characters not bytes).</param>
- /// <exception cref="InvalidOperationException">
- /// This can occur due to the following reasons:
- /// 1) The application does not have the privilege to call this function.
- /// 2) The IME main loop has not started yet.
- /// 3) Invalid parameter.
- /// </exception>
+ /// <exception cref="ArgumentException">This exception can be due to an invalid parameter.</exception>
+ /// <exception cref="UnauthorizedAccessException">This exception can be due to permission denied.</exception>
+ /// <exception cref="InvalidOperationException">The IME main loop has not started yet.</exception>
/// <since_tizen> 4 </since_tizen>
public static void SetSelection(int start, int end)
{
/// http://tizen.org/privilege/ime
/// </privilege>
/// <returns>The input panel main window object on success, otherwise null.</returns>
+ /// <exception cref="UnauthorizedAccessException">This exception can be due to permission denied.</exception>
/// <exception cref="InvalidOperationException">
/// This can occur due to the following reasons:
- /// 1) The application does not have the privilege to call this function.
- /// 2) The IME main loop has not started yet.
- /// 3) Operation failed.
+ /// 1) The IME main loop has not started yet.
+ /// 2) Operation failed.
/// </exception>
/// <since_tizen> 4 </since_tizen>
+ [Obsolete("Deprecated since API10. Will be removed in API12.")]
public static EditorWindow GetMainWindow()
{
EditorWindow._handle = ImeGetMainWindow();
/// <privilege>
/// http://tizen.org/privilege/ime
/// </privilege>
- /// <exception cref="InvalidOperationException">
- /// This can occur due to the following reasons:
- /// 1) The application does not have the privilege to call this function.
- /// 2) The IME main loop has not started yet.
- /// </exception>
+ /// <exception cref="UnauthorizedAccessException">This exception can be due to permission denied.</exception>
+ /// <exception cref="InvalidOperationException">The IME main loop has not started yet.</exception>
/// <since_tizen> 5 </since_tizen>
public static void RequestHide()
{
/// <privilege>
/// http://tizen.org/privilege/ime
/// </privilege>
- /// <exception cref="InvalidOperationException">
- /// This can occur due to the following reasons:
- /// 1) The application does not have the privilege to call this function.
- /// 2) Operation failed.
- /// </exception>
+ /// <exception cref="UnauthorizedAccessException">This exception can be due to permission denied.</exception>
+ /// <exception cref="InvalidOperationException">This exception can be due to operation failed.</exception>
/// <since_tizen> 4 </since_tizen>
[EditorBrowsable(EditorBrowsableState.Never)]
public static void Create()
/// <privilege>
/// http://tizen.org/privilege/ime
/// </privilege>
- /// <exception cref="InvalidOperationException">
- /// This can occur due to the following reasons:
- /// 1) The application does not have the privilege to call this function.
- /// 2) Operation failed.
- /// </exception>
+ /// <exception cref="UnauthorizedAccessException">This exception can be due to permission denied.</exception>
/// <since_tizen> 4 </since_tizen>
[EditorBrowsable(EditorBrowsableState.Never)]
public static void Destroy()
/// http://tizen.org/privilege/ime
/// </privilege>
/// <param name="floatingMode"><c>true</c> to set the floating mode to on and <c>false</c> to set it to off.</param>
- /// <exception cref="InvalidOperationException">
- /// This can occur due to the following reasons:
- /// 1) The application does not have the privilege to call this function.
- /// 2) The IME main loop has not started yet.
- /// </exception>
+ /// <exception cref="UnauthorizedAccessException">This exception can be due to permission denied.</exception>
+ /// <exception cref="InvalidOperationException">The IME main loop has not started yet.</exception>
/// <since_tizen> 5 </since_tizen>
public static void SetFloatingMode(bool floatingMode)
{
/// <remarks>
/// This function can be used in floating mode. If the floating mode is deactivated, calling this function has no effect.
/// </remarks>
- /// <exception cref="InvalidOperationException">
- /// This can occur due to the following reasons:
- /// 1) The application does not have the privilege to call this function.
- /// 2) The IME main loop has not started yet.
- /// </exception>
+ /// <exception cref="UnauthorizedAccessException">This exception can be due to permission denied.</exception>
+ /// <exception cref="InvalidOperationException">The IME main loop has not started yet.</exception>
/// <since_tizen> 5 </since_tizen>
public static void SetFloatingDragStart()
{
/// <remarks>
/// This function can be used in floating mode. If the floating mode is deactivated, calling this function has no effect.
/// </remarks>
- /// <exception cref="InvalidOperationException">
- /// This can occur due to the following reasons:
- /// 1) The application does not have the privilege to call this function.
- /// 2) The IME main loop has not started yet.
- /// </exception>
+ /// <exception cref="UnauthorizedAccessException">This exception can be due to permission denied.</exception>
+ /// <exception cref="InvalidOperationException">The IME main loop has not started yet.</exception>
/// <since_tizen> 5 </since_tizen>
public static void SetFloatingDragEnd()
{
/// <remarks>
/// LanguageRequestedCallback is raised after this API is called when the App requests changed language information.
/// </remarks>
- /// <exception cref="InvalidOperationException">
- /// This can occur due to the following reasons:
- /// 1) The application does not have the privilege to call this function.
- /// 2) The IME main loop has not started yet.
- /// </exception>
+ /// <exception cref="UnauthorizedAccessException">This exception can be due to permission denied.</exception>
+ /// <exception cref="InvalidOperationException">The IME main loop has not started yet.</exception>
/// <since_tizen> 6 </since_tizen>
public static void SendLanguageUpdated()
{
/// http://tizen.org/privilege/ime
/// </privilege>
/// <param name="enable"><c>true</c> if shift button is clicked, otherwise <c>false</c>.</param>
- /// <exception cref="InvalidOperationException">
- /// This can occur due to the following reasons:
- /// 1) The application does not have the privilege to call this function.
- /// 2) The IME main loop has not started yet.
- /// </exception>
+ /// <exception cref="UnauthorizedAccessException">This exception can be due to permission denied.</exception>
+ /// <exception cref="InvalidOperationException">The IME main loop has not started yet.</exception>
/// <since_tizen> 6 </since_tizen>
public static void SendShiftModeUpdated(bool enable)
{
/// <privilege>
/// http://tizen.org/privilege/ime
/// </privilege>
- /// <exception cref="InvalidOperationException">
- /// This can occur due to the following reasons:
- /// 1) The application does not have the privilege to call this function.
- /// 2) The IME main loop has not started yet.
- /// </exception>
+ /// <exception cref="UnauthorizedAccessException">This exception can be due to permission denied.</exception>
+ /// <exception cref="InvalidOperationException">The IME main loop has not started yet.</exception>
/// <since_tizen> 6 </since_tizen>
public static void SendCustomGeometryUpdated()
{
/// http://tizen.org/privilege/ime
/// </privilege>
/// <returns>The selected text.</returns>
- /// <exception cref="InvalidOperationException">
- /// This can occur due to the following reasons:
- /// 1) The application does not have the privilege to call this function.
- /// 2) The IME main loop has not started yet.
- /// 3) Invalid parameter.
- /// </exception>
+ /// <exception cref="UnauthorizedAccessException">This exception can be due to permission denied.</exception>
+ /// <exception cref="InvalidOperationException">The IME main loop has not started yet.</exception>
/// <since_tizen> 6 </since_tizen>
public static string GetSelectedText()
{
{
add
{
- lock (thisLock)
+ if (_imePredictionHintSetDelegate == null)
{
- if (_imePredictionHintSetDelegate == null)
+ _imePredictionHintSetDelegate = (IntPtr predictionHint, IntPtr userData) =>
+ {
+ PredictionHintUpdatedEventArgs args = new PredictionHintUpdatedEventArgs(Marshal.PtrToStringAnsi(predictionHint));
+ _predictionHintUpdated?.Invoke(null, args);
+ };
+ ErrorCode error = ImeEventSetPredictionHintSetCb(_imePredictionHintSetDelegate, IntPtr.Zero);
+ if (error != ErrorCode.None)
{
- _imePredictionHintSetDelegate = (IntPtr predictionHint, IntPtr userData) =>
- {
- PredictionHintUpdatedEventArgs args = new PredictionHintUpdatedEventArgs(Marshal.PtrToStringAnsi(predictionHint));
- _predictionHintUpdated?.Invoke(null, args);
- };
- ErrorCode error = ImeEventSetPredictionHintSetCb(_imePredictionHintSetDelegate, IntPtr.Zero);
- if (error != ErrorCode.None)
- {
- Log.Error(LogTag, "Add PredictionHintUpdated Failed with error " + error);
- }
+ Log.Error(LogTag, "Add PredictionHintUpdated Failed with error " + error);
}
- _predictionHintUpdated += value;
}
+ _predictionHintUpdated += value;
}
remove
{
- lock (thisLock)
- {
- _predictionHintUpdated -= value;
- }
+ _predictionHintUpdated -= value;
}
}
{
add
{
- lock (thisLock)
+ if (_imePredictionHintDataSetDelegate == null)
{
- if (_imePredictionHintDataSetDelegate == null)
+ _imePredictionHintDataSetDelegate = (IntPtr key, IntPtr keyValue, IntPtr userData) =>
+ {
+ PredictionHintDataUpdatedEventArgs args = new PredictionHintDataUpdatedEventArgs(Marshal.PtrToStringAnsi(key), Marshal.PtrToStringAnsi(keyValue));
+ _predictionHintDataUpdated?.Invoke(null, args);
+ };
+
+ ErrorCode error = ImeEventSetPredictionHintDataSetCb(_imePredictionHintDataSetDelegate, IntPtr.Zero);
+ if (error != ErrorCode.None)
{
- _imePredictionHintDataSetDelegate = (IntPtr key, IntPtr keyValue, IntPtr userData) =>
- {
- PredictionHintDataUpdatedEventArgs args = new PredictionHintDataUpdatedEventArgs(Marshal.PtrToStringAnsi(key), Marshal.PtrToStringAnsi(keyValue));
- _predictionHintDataUpdated?.Invoke(null, args);
- };
-
- ErrorCode error = ImeEventSetPredictionHintDataSetCb(_imePredictionHintDataSetDelegate, IntPtr.Zero);
- if (error != ErrorCode.None)
- {
- Log.Error(LogTag, "Add PredictionHintDataUpdated Failed with error " + error);
- }
+ Log.Error(LogTag, "Add PredictionHintDataUpdated Failed with error " + error);
}
- _predictionHintDataUpdated += value;
}
+ _predictionHintDataUpdated += value;
}
remove
{
- lock (thisLock)
- {
- _predictionHintDataUpdated -= value;
- }
+ _predictionHintDataUpdated -= value;
}
}
{
add
{
- lock (thisLock)
+ if (_imeMimeTypeSetRequestDelegate == null)
{
- if (_imeMimeTypeSetRequestDelegate == null)
+ _imeMimeTypeSetRequestDelegate = (IntPtr mimeType, IntPtr userData) =>
{
- _imeMimeTypeSetRequestDelegate = (IntPtr mimeType, IntPtr userData) =>
- {
- MimeTypeUpdateRequestedEventArgs args = new MimeTypeUpdateRequestedEventArgs(Marshal.PtrToStringAnsi(mimeType));
- _mimeTypeUpdateRequested?.Invoke(null, args);
- };
- ErrorCode error = ImeEventSetMimeTypeSetRequestCb(_imeMimeTypeSetRequestDelegate, IntPtr.Zero);
- if (error != ErrorCode.None)
- {
- Log.Error(LogTag, "Add MimeTypeUpdateRequested Failed with error " + error);
- }
+ MimeTypeUpdateRequestedEventArgs args = new MimeTypeUpdateRequestedEventArgs(Marshal.PtrToStringAnsi(mimeType));
+ _mimeTypeUpdateRequested?.Invoke(null, args);
+ };
+ ErrorCode error = ImeEventSetMimeTypeSetRequestCb(_imeMimeTypeSetRequestDelegate, IntPtr.Zero);
+ if (error != ErrorCode.None)
+ {
+ Log.Error(LogTag, "Add MimeTypeUpdateRequested Failed with error " + error);
}
- _mimeTypeUpdateRequested += value;
}
+ _mimeTypeUpdateRequested += value;
}
remove
{
- lock (thisLock)
- {
- _mimeTypeUpdateRequested -= value;
- }
+ _mimeTypeUpdateRequested -= value;
}
}
/// http://tizen.org/privilege/ime
/// </privilege>
/// <param name="command">The UTF-8 string to be sent.</param>
- /// <exception cref="InvalidOperationException">
- /// This can occur due to the following reasons:
- /// 1) The application does not have the privilege to call this function.
- /// 2) The IME main loop has not started yet.
- /// 3) Invalid parameter.
- /// </exception>
+ /// <exception cref="UnauthorizedAccessException">This exception can be due to permission denied.</exception>
+ /// <exception cref="InvalidOperationException">The IME main loop has not started yet.</exception>
/// <since_tizen> 6 </since_tizen>
public static void SendPrivateCommand(string command)
{
/// <param name="content">The content URI to be sent.</param>
/// <param name="description">The content description.</param>
/// <param name="mimeType">The MIME type received from the MimeTypeSetRequest</param>
- /// <exception cref="InvalidOperationException">
- /// This can occur due to the following reasons:
- /// 1) The application does not have the privilege to call this function.
- /// 2) The IME main loop has not started yet.
- /// 3) Invalid parameter.
- /// </exception>
+ /// <exception cref="UnauthorizedAccessException">This exception can be due to permission denied.</exception>
+ /// <exception cref="InvalidOperationException">The IME main loop has not started yet.</exception>
/// <since_tizen> 6 </since_tizen>
public static void CommitContent(string content, string description, string mimeType)
{
throw InputMethodExceptionFactory.CreateException(error);
}
}
+
+ /// <summary>
+ /// This API updates the given native input panel window's size information.
+ /// The native window handle of NUI Window can be got by below code.
+ /// var handle = new Window.SafeNativeWindowHandle();
+ /// IntPtr nativeHandle = handle.DangerousGetHandle();
+ /// </summary>
+ /// <privilege>
+ /// http://tizen.org/privilege/ime
+ /// </privilege>
+ /// <param name="window">The native window handle.</param>
+ /// <param name="portraitWidth">The width in the portrait mode.</param>
+ /// <param name="portraitHeight">The height in the portrait mode.</param>
+ /// <param name="landscapeWidth">The width in the landscape mode.</param>
+ /// <param name="landscapeHeight">The height in the landscape mode.</param>
+ /// <exception cref="ArgumentException">This exception can be due to an invalid parameter.</exception>
+ /// <exception cref="UnauthorizedAccessException">This exception can be due to permission denied.</exception>
+ /// <exception cref="InvalidOperationException">The IME main loop has not started yet.</exception>
+ /// <since_tizen> 9 </since_tizen>
+ public static void SetSize(IntPtr window, int portraitWidth, int portraitHeight, int landscapeWidth, int landscapeHeight)
+ {
+ ErrorCode error = ImeSetNativeWindowSize(window, portraitWidth, portraitHeight, landscapeWidth, landscapeHeight);
+ if (error != ErrorCode.None)
+ {
+ Log.Error(LogTag, "SetSize Failed with error " + error);
+ throw InputMethodExceptionFactory.CreateException(error);
+ }
+ }
+
+ /// <summary>
+ /// Sets the processKey action.
+ /// If the key event is from the external device, DeviceInfo will have its name, class, and subclass information.
+ /// </summary>
+ /// <param name="processKey">
+ /// <c>true</c> if the event was processed, otherwise the event was not processed and was forwarded to the client application.
+ /// The first parameter is X11 key code and the second parameter is key symbol.
+ /// The action is called when the key event is received from the external devices or the SendKey function.
+ /// This Event processes the key event before an associated text input UI control does.
+ /// </param>
+ /// <since_tizen> 10 </since_tizen>
+ public static void SetProcessKeyCallback(BoolAction<uint, KeyCode, KeyMask, InputMethodDeviceInformation> processKey)
+ {
+ _imeProcessKeyWithKeycodeDelegate = (uint keyCode, KeyCode keySymbol, KeyMask keyMask, IntPtr devInfo, IntPtr userData) =>
+ {
+ return _processKeyWithKeycodeDelagate(keyCode, keySymbol, keyMask, new InputMethodDeviceInformation(devInfo));
+ };
+ ErrorCode error = ImeEventSetProcessKeyEventWithKeycodeCb(_imeProcessKeyWithKeycodeDelegate, IntPtr.Zero);
+ if (error != ErrorCode.None)
+ {
+ Log.Error(LogTag, "Add ProcessKeyWithKeycode Failed with error " + error);
+ }
+ _processKeyWithKeycodeDelagate = processKey;
+ }
+
+ /// <summary>
+ /// Updates the cursor position in the preedit string.
+ /// </summary>
+ /// <privilege>
+ /// http://tizen.org/privilege/ime
+ /// </privilege>
+ /// <param name="position">The cursor position in the preedit string.</param>
+ /// <exception cref="UnauthorizedAccessException">This exception can be due to permission denied.</exception>
+ /// <exception cref="InvalidOperationException">The IME main loop has not started yet.</exception>
+ /// <since_tizen> 10 </since_tizen>
+ public static void UpdatePreeditCursor(uint position)
+ {
+ ErrorCode error = ImeUpdatePreeditCursor(position);
+ if (error != ErrorCode.None)
+ {
+ Log.Error(LogTag, "UpdatePreeditCursor Failed with error " + error);
+ throw InputMethodExceptionFactory.CreateException(error);
+ }
+ }
+
+ /// <summary>
+ /// Sets whether candidate strings will be shown or not.
+ /// </summary>
+ /// <privilege>
+ /// http://tizen.org/privilege/ime
+ /// </privilege>
+ /// <param name="visible"><c>true</c> to show candidate strings, <c>false</c> otherwise.</param>
+ /// <exception cref="UnauthorizedAccessException">This exception can be due to permission denied.</exception>
+ /// <exception cref="InvalidOperationException">The IME main loop has not started yet.</exception>
+ /// <since_tizen> 10 </since_tizen>
+ public static void SetCandidateVisibilityState(bool visible)
+ {
+ ErrorCode error = ImeSetCandidateVisibilityState(visible);
+ if (error != ErrorCode.None)
+ {
+ Log.Error(LogTag, "SetCandidateVisibilityState Failed with error " + error);
+ throw InputMethodExceptionFactory.CreateException(error);
+ }
+ }
+
+ /// <summary>
+ /// Called when an associated text input UI control requests the input panel to set its input hint.
+ /// It will only be called when the client application changes the edit field's input hint attribute after the input panel is shown.
+ /// </summary>
+ /// <seealso cref="InputHints"/>
+ /// <since_tizen> 10 </since_tizen>
+ public static event EventHandler<InputHintSetEventArgs> InputHintSet
+ {
+ add
+ {
+ _imeInputHintSetDelegate = (InputHints hint, IntPtr userData) =>
+ {
+ InputHintSetEventArgs args = new InputHintSetEventArgs(hint);
+ _inputHintSet?.Invoke(null, args);
+ };
+ ErrorCode error = ImeEventSetInputHintSetCb(_imeInputHintSetDelegate, IntPtr.Zero);
+ if (error != ErrorCode.None)
+ {
+ Log.Error(LogTag, "Add InputHintSet Failed with error " + error);
+ }
+ else
+ {
+ _inputHintSet += value;
+ }
+ }
+ remove
+ {
+ _inputHintSet -= value;
+ }
+ }
}
}