[DllImport(Libraries.InputMethod, EntryPoint = "ime_update_input_panel_event")]
internal static extern ErrorCode ImeUpdateInputPanelEvent(ImeEventType type, uint value);
+ [DllImport(Libraries.InputMethod, EntryPoint = "ime_get_selected_text")]
+ internal static extern ErrorCode ImeGetSelectedText(out IntPtr text);
+
+ [DllImport(Libraries.InputMethod, EntryPoint = "ime_event_set_prediction_hint_set_cb")]
+ internal static extern ErrorCode ImeEventSetPredictionHintSetCb(ImePredictionHintSetCb callbackFunction, IntPtr userData);
+
+ [DllImport(Libraries.InputMethod, EntryPoint = "ime_event_set_prediction_hint_data_set_cb")]
+ internal static extern ErrorCode ImeEventSetPredictionHintDataSetCb(ImePredictionHintDataSetCb callbackFunction, IntPtr userData);
+
+ [DllImport(Libraries.InputMethod, EntryPoint = "ime_event_set_mime_type_set_request_cb")]
+ internal static extern ErrorCode ImeEventSetMimeTypeSetRequestCb(ImeMimeTypeSetRequestCb callbackFunction, IntPtr userData);
+
+ [DllImport(Libraries.InputMethod, EntryPoint = "ime_send_private_command")]
+ internal static extern ErrorCode ImeSendPrivateCommand(string command);
+
+ [DllImport(Libraries.InputMethod, EntryPoint = "ime_commit_content")]
+ internal static extern ErrorCode ImeCommitContent(string content, string description, string mimeType);
+
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
internal delegate void ImeCreateCb(IntPtr userData);
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
internal delegate void ImeAccessibilityStateChangedCb(bool state, IntPtr userData);
+
+ [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
+ internal delegate void ImePredictionHintSetCb(IntPtr predictionHint, IntPtr userData);
+
+ [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
+ internal delegate void ImePredictionHintDataSetCb(IntPtr key, IntPtr keyValue, IntPtr userData);
+
+ [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
+ internal delegate void ImeMimeTypeSetRequestCb(IntPtr mimeType, IntPtr userData);
}
}
private static ImeRotationChangedCb _imeRotationChangedDelegate;
private static event EventHandler<AccessibilityStateChangedEventArgs> _accessibilityStateChanged;
private static ImeAccessibilityStateChangedCb _imeAccessibilityStateChangedDelegate;
+ private static event EventHandler<PredictionHintUpdatedEventArgs> _predictionHintUpdated;
+ private static ImePredictionHintSetCb _imePredictionHintSetDelegate;
+ private static event EventHandler<PredictionHintDataUpdatedEventArgs> _predictionHintDataUpdated;
+ private static ImePredictionHintDataSetCb _imePredictionHintDataSetDelegate;
+ private static event EventHandler<MimeTypeUpdateRequestedEventArgs> _mimeTypeUpdateRequested;
+ private static ImeMimeTypeSetRequestCb _imeMimeTypeSetRequestDelegate;
private static ImeLanguageRequestedCb _imeLanguageRequestedDelegate;
private static OutAction<string> _languageRequestedDelegate;
private static BoolAction<KeyCode, KeyMask, InputMethodDeviceInformation> _processKeyDelagate;
throw InputMethodExceptionFactory.CreateException(error);
}
}
+
+ /// <summary>
+ /// Gets the selected text synchronously.
+ /// </summary>
+ /// <privilege>
+ /// 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>
+ /// <since_tizen> 6 </since_tizen>
+ public static string GetSelectedText()
+ {
+ IntPtr txt;
+ ErrorCode error = ImeGetSelectedText(out txt);
+ if (error != ErrorCode.None)
+ {
+ Log.Error(LogTag, "GetSelectedText Failed with error " + error);
+ throw InputMethodExceptionFactory.CreateException(error);
+ }
+ return Marshal.PtrToStringAnsi(txt);
+ }
+
+ /// <summary>
+ /// Called to set the prediction hint string to deliver to the input panel.
+ /// </summary>
+ /// <since_tizen> 6 </since_tizen>
+ public static event EventHandler<PredictionHintUpdatedEventArgs> PredictionHintUpdated
+ {
+ add
+ {
+ lock (thisLock)
+ {
+ 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)
+ {
+ Log.Error(LogTag, "Add PredictionHintUpdated Failed with error " + error);
+ }
+ }
+ _predictionHintUpdated += value;
+ }
+ }
+ remove
+ {
+ lock (thisLock)
+ {
+ _predictionHintUpdated -= value;
+ }
+ }
+ }
+
+ /// <summary>
+ /// Called to set the prediction hint key and value to deliver to the input panel.
+ /// </summary>
+ /// <since_tizen> 6 </since_tizen>
+ public static event EventHandler<PredictionHintDataUpdatedEventArgs> PredictionHintDataUpdated
+ {
+ add
+ {
+ lock (thisLock)
+ {
+ 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)
+ {
+ Log.Error(LogTag, "Add PredictionHintDataUpdated Failed with error " + error);
+ }
+ }
+ _predictionHintDataUpdated += value;
+ }
+ }
+ remove
+ {
+ lock (thisLock)
+ {
+ _predictionHintDataUpdated -= value;
+ }
+ }
+ }
+
+ /// <summary>
+ /// Called when an associated text input UI control requests the text entry to set the MIME type.
+ /// </summary>
+ /// <since_tizen> 6 </since_tizen>
+ public static event EventHandler<MimeTypeUpdateRequestedEventArgs> MimeTypeUpdateRequested
+ {
+ add
+ {
+ lock (thisLock)
+ {
+ if (_imeMimeTypeSetRequestDelegate == null)
+ {
+ _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);
+ }
+ }
+ _mimeTypeUpdateRequested += value;
+ }
+ }
+ remove
+ {
+ lock (thisLock)
+ {
+ _mimeTypeUpdateRequested -= value;
+ }
+ }
+ }
+
+ /// <summary>
+ /// Sends a private command to the associated text input UI control.
+ /// </summary>
+ /// <privilege>
+ /// 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>
+ /// <since_tizen> 6 </since_tizen>
+ public static void SendPrivateCommand(string command)
+ {
+ ErrorCode error = ImeSendPrivateCommand(command);
+ if (error != ErrorCode.None)
+ {
+ Log.Error(LogTag, "SendPrivateCommand Failed with error " + error);
+ throw InputMethodExceptionFactory.CreateException(error);
+ }
+ }
+
+ /// <summary>
+ /// Commits contents such as image to the associated text input UI control.
+ /// </summary>
+ /// <privilege>
+ /// http://tizen.org/privilege/ime
+ /// </privilege>
+ /// <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>
+ /// <since_tizen> 6 </since_tizen>
+ public static void CommitContent(string content, string description, string mimeType)
+ {
+ ErrorCode error = ImeCommitContent(content, description, mimeType);
+ if (error != ErrorCode.None)
+ {
+ Log.Error(LogTag, "CommitContent Failed with error " + error);
+ throw InputMethodExceptionFactory.CreateException(error);
+ }
+ }
}
}
--- /dev/null
+/*
+* Copyright (c) 2018 Samsung Electronics Co., Ltd All Rights Reserved
+*
+* Licensed under the Apache License, Version 2.0 (the License);
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an AS IS BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+
+namespace Tizen.Uix.InputMethod
+{
+ /// <summary>
+ /// This class contains the data related to the PredictionHintDataUpdated event.
+ /// </summary>
+ /// <since_tizen> 6 </since_tizen>
+ public class PredictionHintDataUpdatedEventArgs
+ {
+ internal PredictionHintDataUpdatedEventArgs(string key, string value)
+ {
+ Key = key;
+ Value = value;
+ }
+
+ /// <summary>
+ /// The prediction hint key.
+ /// </summary>
+ /// <since_tizen> 6 </since_tizen>
+ public string Key { get; }
+
+ /// <summary>
+ /// The prediction hint value.
+ /// </summary>
+ /// <since_tizen> 6 </since_tizen>
+ public string Value { get; }
+ }
+}
+
--- /dev/null
+/*
+* Copyright (c) 2018 Samsung Electronics Co., Ltd All Rights Reserved
+*
+* Licensed under the Apache License, Version 2.0 (the License);
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an AS IS BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+
+namespace Tizen.Uix.InputMethod
+{
+ /// <summary>
+ /// This class contains the data related to the PredictionHintUpdated event.
+ /// </summary>
+ /// <since_tizen> 6 </since_tizen>
+ public class PredictionHintUpdatedEventArgs
+ {
+ internal PredictionHintUpdatedEventArgs(string predictionHint)
+ {
+ PredictionHint = predictionHint;
+ }
+
+ /// <summary>
+ /// The prediction hint to be set to the input panel
+ /// </summary>
+ /// <since_tizen> 6 </since_tizen>
+ public string PredictionHint { get; }
+ }
+}
+