2 * Copyright(c) 2018 Samsung Electronics Co., Ltd.
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.Runtime.InteropServices;
20 using System.ComponentModel;
25 /// Specifically manages the input method framework (IMF) that enables the virtual or hardware keyboards.
27 /// <since_tizen> 5 </since_tizen>
28 public class InputMethodContext : BaseHandle
30 private global::System.Runtime.InteropServices.HandleRef swigCPtr;
32 private ActivatedEventCallbackType _activatedEventCallback;
33 private EventReceivedEventCallbackType _eventReceivedEventCallback;
34 private StatusChangedEventCallbackType _statusChangedEventCallback;
35 private ResizedEventCallbackType _resizedEventCallback;
36 private LanguageChangedEventCallbackType _languageChangedEventCallback;
37 private KeyboardTypeChangedEventCallbackType _keyboardTypeChangedEventCallback;
42 /// <since_tizen> 5 </since_tizen>
43 public InputMethodContext() : this(NDalicManualPINVOKE.InputMethodContext_New(), true)
45 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
49 internal InputMethodContext(IntPtr cPtr, bool cMemoryOwn) : base(NDalicManualPINVOKE.InputMethodContext_SWIGUpcast(cPtr), cMemoryOwn)
51 swigCPtr = new global::System.Runtime.InteropServices.HandleRef(this, cPtr);
54 [UnmanagedFunctionPointer(CallingConvention.StdCall)]
55 private delegate void ActivatedEventCallbackType(IntPtr data);
56 private delegate IntPtr EventReceivedEventCallbackType(IntPtr inputMethodContext, IntPtr eventData);
57 private delegate void StatusChangedEventCallbackType(bool statusChanged);
58 private delegate void ResizedEventCallbackType(int resized);
59 private delegate void LanguageChangedEventCallbackType(int languageChanged);
60 private delegate void KeyboardTypeChangedEventCallbackType(KeyboardType type);
62 private event EventHandler<ActivatedEventArgs> _activatedEventHandler;
63 private event EventHandlerWithReturnType<object, EventReceivedEventArgs, CallbackData> _eventReceivedEventHandler;
64 private event EventHandler<StatusChangedEventArgs> _statusChangedEventHandler;
65 private event EventHandler<ResizedEventArgs> _resizedEventHandler;
66 private event EventHandler<LanguageChangedEventArgs> _languageChangedEventHandler;
67 private event EventHandler<KeyboardTypeChangedEventArgs> _keyboardTypeChangedEventHandler;
70 /// InputMethodContext activated.
72 /// <since_tizen> 5 </since_tizen>
73 public event EventHandler<ActivatedEventArgs> Activated
77 if (_activatedEventHandler == null)
79 _activatedEventCallback = OnActivated;
80 ActivatedSignal().Connect(_activatedEventCallback);
83 _activatedEventHandler += value;
87 _activatedEventHandler -= value;
89 if (_activatedEventHandler == null && _activatedEventCallback != null)
91 ActivatedSignal().Disconnect(_activatedEventCallback);
97 /// InputMethodContext event received.
99 /// <since_tizen> 5 </since_tizen>
100 public event EventHandlerWithReturnType<object, EventReceivedEventArgs, CallbackData> EventReceived
104 if (_eventReceivedEventHandler == null)
106 _eventReceivedEventCallback = OnEventReceived;
107 EventReceivedSignal().Connect(_eventReceivedEventCallback);
110 _eventReceivedEventHandler += value;
114 _eventReceivedEventHandler -= value;
116 if (_eventReceivedEventHandler == null && _eventReceivedEventCallback != null)
118 EventReceivedSignal().Disconnect(_eventReceivedEventCallback);
124 /// InputMethodContext status changed.
126 /// <since_tizen> 5 </since_tizen>
127 public event EventHandler<StatusChangedEventArgs> StatusChanged
131 if (_statusChangedEventHandler == null)
133 _statusChangedEventCallback = OnStatusChanged;
134 StatusChangedSignal().Connect(_statusChangedEventCallback);
137 _statusChangedEventHandler += value;
141 _statusChangedEventHandler -= value;
143 if (_statusChangedEventHandler == null && _statusChangedEventCallback != null)
145 StatusChangedSignal().Disconnect(_statusChangedEventCallback);
151 /// InputMethodContext resized.
153 /// <since_tizen> 5 </since_tizen>
154 public event EventHandler<ResizedEventArgs> Resized
158 if (_resizedEventHandler == null)
160 _resizedEventCallback = OnResized;
161 ResizedSignal().Connect(_resizedEventCallback);
164 _resizedEventHandler += value;
168 _resizedEventHandler -= value;
170 if (_resizedEventHandler == null && _resizedEventCallback != null)
172 ResizedSignal().Disconnect(_resizedEventCallback);
178 /// InputMethodContext language changed.
180 /// <since_tizen> 5 </since_tizen>
181 public event EventHandler<LanguageChangedEventArgs> LanguageChanged
185 if (_languageChangedEventHandler == null)
187 _languageChangedEventCallback = OnLanguageChanged;
188 LanguageChangedSignal().Connect(_languageChangedEventCallback);
191 _languageChangedEventHandler += value;
195 _languageChangedEventHandler -= value;
197 if (_languageChangedEventHandler == null && _languageChangedEventCallback != null)
199 LanguageChangedSignal().Disconnect(_languageChangedEventCallback);
205 /// InputMethodContext keyboard type changed.
207 /// <since_tizen> 5 </since_tizen>
208 public event EventHandler<KeyboardTypeChangedEventArgs> KeyboardTypeChanged
212 if (_keyboardTypeChangedEventHandler == null)
214 _keyboardTypeChangedEventCallback = OnKeyboardTypeChanged;
215 KeyboardTypeChangedSignal().Connect(_keyboardTypeChangedEventCallback);
218 _keyboardTypeChangedEventHandler += value;
222 _keyboardTypeChangedEventHandler -= value;
224 if (_keyboardTypeChangedEventHandler == null && _keyboardTypeChangedEventCallback != null)
226 KeyboardTypeChangedSignal().Disconnect(_keyboardTypeChangedEventCallback);
232 /// The direction of the text.
234 /// <since_tizen> 5 </since_tizen>
235 public enum TextDirection
248 /// Events that are generated by the IMF.
250 /// <since_tizen> 5 </since_tizen>
251 public enum EventType
256 /// <since_tizen> 5 </since_tizen>
259 /// Pre-edit changed.
261 /// <since_tizen> 5 </since_tizen>
266 /// <since_tizen> 5 </since_tizen>
269 /// An event to delete a range of characters from the string.
271 /// <since_tizen> 5 </since_tizen>
274 /// An event to query string and the cursor position.
276 /// <since_tizen> 5 </since_tizen>
279 /// Private command sent from the input panel.
281 /// <since_tizen> 5 </since_tizen>
286 /// Enumeration for the state of the input panel.
288 /// <since_tizen> 5 </since_tizen>
294 /// <since_tizen> 5 </since_tizen>
297 /// Input panel is shown.
299 /// <since_tizen> 5 </since_tizen>
302 /// Input panel is hidden.
304 /// <since_tizen> 5 </since_tizen>
307 /// Input panel in process of being shown.
309 /// <since_tizen> 5 </since_tizen>
314 /// Enumeration for the types of keyboard.
316 /// <since_tizen> 5 </since_tizen>
317 public enum KeyboardType
320 /// Software keyboard (virtual keyboard) is default.
322 /// <since_tizen> 5 </since_tizen>
325 /// Hardware keyboard.
327 /// <since_tizen> 5 </since_tizen>
332 /// Gets or sets whether the IM context allows to use the text prediction.
334 /// This will be public opened in tizen_5.0 after ACR done. Before ACR, need to be hidden as inhouse API.
335 [EditorBrowsable(EditorBrowsableState.Never)]
336 public bool TextPrediction
340 return IsTextPredictionAllowed();
344 AllowTextPrediction(value);
349 /// Destroys the context of the IMF.<br/>
351 /// <since_tizen> 5 </since_tizen>
352 public void DestroyContext()
354 NDalicManualPINVOKE.InputMethodContext_Finalize(swigCPtr);
355 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
359 /// Activates the IMF.<br/>
360 /// It means that the text editing has started.<br/>
361 /// If the hardware keyboard is not connected, then it shows the virtual keyboard.
363 /// <since_tizen> 5 </since_tizen>
364 public void Activate()
366 NDalicManualPINVOKE.InputMethodContext_Activate(swigCPtr);
367 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
371 /// Deactivates the IMF.<br/>
372 /// It means that the text editing is complete.
374 /// <since_tizen> 5 </since_tizen>
375 public void Deactivate()
377 NDalicManualPINVOKE.InputMethodContext_Deactivate(swigCPtr);
378 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
382 /// Gets the restoration status, which controls if the keyboard is restored after the focus is lost and then regained.<br/>
383 /// If true, then the keyboard will be restored (activated) after the focus is regained.
385 /// <returns>The restoration status.</returns>
386 /// <since_tizen> 5 </since_tizen>
387 public bool RestoreAfterFocusLost()
389 bool ret = NDalicManualPINVOKE.InputMethodContext_RestoreAfterFocusLost(swigCPtr);
390 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
395 /// Sets the status whether the IMF has to restore the keyboard after losing focus.
397 /// <param name="toggle">True means that keyboard must be restored after the focus is lost and regained.</param>
398 /// <since_tizen> 5 </since_tizen>
399 public void SetRestoreAfterFocusLost(bool toggle)
401 NDalicManualPINVOKE.InputMethodContext_SetRestoreAfterFocusLost(swigCPtr, toggle);
402 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
406 /// Sends a message reset to the pre-edit state or the IMF module.
408 /// <since_tizen> 5 </since_tizen>
409 public new void Reset()
411 NDalicManualPINVOKE.InputMethodContext_Reset(swigCPtr);
412 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
416 /// Notifies the IMF context that the cursor position has changed, required for features such as auto-capitalization.
418 /// <since_tizen> 5 </since_tizen>
419 public void NotifyCursorPosition()
421 NDalicManualPINVOKE.InputMethodContext_NotifyCursorPosition(swigCPtr);
422 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
426 /// Sets the cursor position stored in VirtualKeyboard, this is required by the IMF context.
428 /// <param name="cursorPosition">The position of the cursor.</param>
429 /// <since_tizen> 5 </since_tizen>
430 public void SetCursorPosition(uint cursorPosition)
432 NDalicManualPINVOKE.InputMethodContext_SetCursorPosition(swigCPtr, cursorPosition);
433 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
437 /// Gets the cursor position stored in VirtualKeyboard, this is required by the IMF context.
439 /// <returns>The current position of the cursor.</returns>
440 /// <since_tizen> 5 </since_tizen>
441 public uint GetCursorPosition()
443 uint ret = NDalicManualPINVOKE.InputMethodContext_GetCursorPosition(swigCPtr);
444 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
449 /// A method to store the string required by the IMF, this is used to provide predictive word suggestions.
451 /// <param name="text">The text string surrounding the current cursor point.</param>
452 /// <since_tizen> 5 </since_tizen>
453 public void SetSurroundingText(string text)
455 NDalicManualPINVOKE.InputMethodContext_SetSurroundingText(swigCPtr, text);
456 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
460 /// Gets the current text string set within the IMF manager, this is used to offer predictive suggestions.
462 /// <returns>The surrounding text.</returns>
463 /// <since_tizen> 5 </since_tizen>
464 public string GetSurroundingText()
466 string ret = NDalicManualPINVOKE.InputMethodContext_GetSurroundingText(swigCPtr);
467 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
472 /// Notifies the IMF context that text input is set to multiline or not.
474 /// <param name="multiLine">True if multiline text input is used.</param>
475 /// <since_tizen> 5 </since_tizen>
476 public void NotifyTextInputMultiLine(bool multiLine)
478 NDalicManualPINVOKE.InputMethodContext_NotifyTextInputMultiLine(swigCPtr, multiLine);
479 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
483 /// Returns the text direction of the current input language of the keyboard.
485 /// <returns>The direction of the text.</returns>
486 /// <since_tizen> 5 </since_tizen>
487 public InputMethodContext.TextDirection GetTextDirection()
489 InputMethodContext.TextDirection ret = (InputMethodContext.TextDirection)NDalicManualPINVOKE.InputMethodContext_GetTextDirection(swigCPtr);
490 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
495 /// Provides the size and the position of the keyboard.<br/>
496 /// The position is relative to whether the keyboard is visible or not.<br/>
497 /// If the keyboard is not visible, then the position will be off the screen.<br/>
498 /// If the keyboard is not being shown when this method is called, the keyboard is partially setup (IMFContext) to get/>
499 /// the values then taken down. So ideally, GetInputMethodArea() must be called after Show().
501 /// <returns>Rectangle which is keyboard panel x, y, width, and height.</returns>
502 /// <since_tizen> 5 </since_tizen>
503 public Rectangle GetInputMethodArea()
505 Rectangle ret = new Rectangle(NDalicManualPINVOKE.InputMethodContext_GetInputMethodArea(swigCPtr), true);
506 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
511 /// Sets up the input panel specific data.
513 /// <param name="text">The specific data to be set to the input panel.</param>
514 /// <since_tizen> 5 </since_tizen>
515 public void SetInputPanelUserData(string text)
517 NDalicManualPINVOKE.InputMethodContext_SetInputPanelUserData(swigCPtr, text);
518 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
522 /// Gets the specific data of the current active input panel.
524 /// <param name="text">The specific data to be received from the input panel.</param>
525 /// <since_tizen> 5 </since_tizen>
526 public void GetInputPanelUserData(out string text)
528 NDalicManualPINVOKE.InputMethodContext_GetInputPanelUserData(swigCPtr, out text);
529 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
533 /// Gets the state of the current active input panel.
535 /// <returns>The state of the input panel.</returns>
536 /// <since_tizen> 5 </since_tizen>
537 public InputMethodContext.State GetInputPanelState()
539 InputMethodContext.State ret = (InputMethodContext.State)NDalicManualPINVOKE.InputMethodContext_GetInputPanelState(swigCPtr);
540 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
545 /// Sets the return key on the input panel to be visible or invisible.<br/>
546 /// The default value is true.
548 /// <param name="visible">True if the return key is visible (enabled), false otherwise.</param>
549 /// <since_tizen> 5 </since_tizen>
550 public void SetReturnKeyState(bool visible)
552 NDalicManualPINVOKE.InputMethodContext_SetReturnKeyState(swigCPtr, visible);
553 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
557 /// Enables to show the input panel automatically when focused.
559 /// <param name="enabled">If true, the input panel will be shown when focused.</param>
560 /// <since_tizen> 5 </since_tizen>
561 public void AutoEnableInputPanel(bool enabled)
563 NDalicManualPINVOKE.InputMethodContext_AutoEnableInputPanel(swigCPtr, enabled);
564 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
568 /// Shows the input panel.
570 /// <since_tizen> 5 </since_tizen>
571 public void ShowInputPanel()
573 NDalicManualPINVOKE.InputMethodContext_ShowInputPanel(swigCPtr);
574 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
578 /// Hides the input panel.
580 /// <since_tizen> 5 </since_tizen>
581 public void HideInputPanel()
583 NDalicManualPINVOKE.InputMethodContext_HideInputPanel(swigCPtr);
584 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
588 /// Gets the keyboard type.<br/>
589 /// The default keyboard type is SoftwareKeyboard.
591 /// <returns>The keyboard type.</returns>
592 /// <since_tizen> 5 </since_tizen>
593 public InputMethodContext.KeyboardType GetKeyboardType()
595 InputMethodContext.KeyboardType ret = (InputMethodContext.KeyboardType)NDalicManualPINVOKE.InputMethodContext_GetKeyboardType(swigCPtr);
596 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
601 /// Gets the current language locale of the input panel.<br/>
602 /// For example, en_US, en_GB, en_PH, fr_FR, and so on.
604 /// <returns>The current language locale of the input panel.</returns>
605 /// <since_tizen> 5 </since_tizen>
606 public string GetInputPanelLocale()
608 string ret = NDalicManualPINVOKE.InputMethodContext_GetInputPanelLocale(swigCPtr);
609 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
613 internal static global::System.Runtime.InteropServices.HandleRef getCPtr(InputMethodContext obj)
615 return (obj == null) ? new global::System.Runtime.InteropServices.HandleRef(null, IntPtr.Zero) : obj.swigCPtr;
618 internal InputMethodContext(InputMethodContext inputMethodContext) : this(NDalicManualPINVOKE.new_InputMethodContext__SWIG_1(InputMethodContext.getCPtr(inputMethodContext)), true)
620 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
623 internal InputMethodContext Assign(InputMethodContext inputMethodContext)
625 InputMethodContext ret = new InputMethodContext(NDalicManualPINVOKE.InputMethodContext_Assign(swigCPtr, InputMethodContext.getCPtr(inputMethodContext)), false);
626 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
630 internal static InputMethodContext DownCast(BaseHandle handle)
632 InputMethodContext ret = new InputMethodContext(NDalicManualPINVOKE.InputMethodContext_DownCast(BaseHandle.getCPtr(handle)), true);
633 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
637 internal void ApplyOptions(InputMethodOptions options)
639 NDalicManualPINVOKE.InputMethodContext_ApplyOptions(swigCPtr, InputMethodOptions.getCPtr(options));
640 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
643 internal void AllowTextPrediction(bool prediction)
645 NDalicManualPINVOKE.InputMethodContext_AllowTextPrediction(swigCPtr, prediction);
646 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
649 internal bool IsTextPredictionAllowed()
651 bool ret = NDalicManualPINVOKE.InputMethodContext_IsTextPredictionAllowed(swigCPtr);
652 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
656 internal ActivatedSignalType ActivatedSignal()
658 ActivatedSignalType ret = new ActivatedSignalType(NDalicManualPINVOKE.InputMethodContext_ActivatedSignal(swigCPtr), false);
659 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
663 internal KeyboardEventSignalType EventReceivedSignal()
665 KeyboardEventSignalType ret = new KeyboardEventSignalType(NDalicManualPINVOKE.InputMethodContext_EventReceivedSignal(swigCPtr), false);
666 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
670 internal StatusSignalType StatusChangedSignal()
672 StatusSignalType ret = new StatusSignalType(NDalicManualPINVOKE.InputMethodContext_StatusChangedSignal(swigCPtr), false);
673 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
677 internal KeyboardResizedSignalType ResizedSignal()
679 KeyboardResizedSignalType ret = new KeyboardResizedSignalType(NDalicManualPINVOKE.InputMethodContext_ResizedSignal(swigCPtr), false);
680 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
684 internal LanguageChangedSignalType LanguageChangedSignal()
686 LanguageChangedSignalType ret = new LanguageChangedSignalType(NDalicManualPINVOKE.InputMethodContext_LanguageChangedSignal(swigCPtr), false);
687 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
691 internal KeyboardTypeSignalType KeyboardTypeChangedSignal()
693 KeyboardTypeSignalType ret = new KeyboardTypeSignalType(NDalicManualPINVOKE.InputMethodContext_KeyboardTypeChangedSignal(swigCPtr), false);
694 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
699 /// You can override it to clean-up your own resources.
701 /// <param name="type">Dispose Type</param>
702 /// <since_tizen> 5 </since_tizen>
703 /// Please do not use! This will be deprecated!
704 /// Dispose() method in Singletone classes (ex: FocusManager, StyleManager, VisualFactory, InputMethodContext, TtsPlayer, Window) is not required.
705 [EditorBrowsable(EditorBrowsableState.Never)]
706 protected override void Dispose(DisposeTypes type)
713 if (type == DisposeTypes.Explicit)
716 //Release your own managed resources here.
717 //You should release all of your own disposable objects here.
721 //Release your own unmanaged resources here.
722 //You should not access any managed member here except static instance
723 //because the execution order of Finalizes is non-deterministic.
725 if (_keyboardTypeChangedEventCallback != null)
727 KeyboardTypeChangedSignal().Disconnect(_keyboardTypeChangedEventCallback);
730 if (swigCPtr.Handle != global::System.IntPtr.Zero)
735 NDalicManualPINVOKE.delete_InputMethodContext(swigCPtr);
737 swigCPtr = new global::System.Runtime.InteropServices.HandleRef(null, IntPtr.Zero);
743 private void OnActivated(IntPtr data)
745 ActivatedEventArgs e = new ActivatedEventArgs();
749 e.InputMethodContext = Registry.GetManagedBaseHandleFromNativePtr(data) as InputMethodContext;
752 if (_activatedEventHandler != null)
754 _activatedEventHandler(this, e);
758 private IntPtr OnEventReceived(IntPtr inputMethodContext, IntPtr eventData)
760 CallbackData callbackData = null;
762 EventReceivedEventArgs e = new EventReceivedEventArgs();
764 if (inputMethodContext != null)
766 e.InputMethodContext = Registry.GetManagedBaseHandleFromNativePtr(inputMethodContext) as InputMethodContext;
768 if (eventData != null)
770 e.EventData = EventData.GetEventDataFromPtr(eventData);
773 if (_eventReceivedEventHandler != null)
775 callbackData = _eventReceivedEventHandler(this, e);
777 if (callbackData != null)
779 return callbackData.GetCallbackDataPtr();
783 return new CallbackData().GetCallbackDataPtr();
787 private void OnStatusChanged(bool statusChanged)
789 StatusChangedEventArgs e = new StatusChangedEventArgs();
791 e.StatusChanged = statusChanged;
793 if (_statusChangedEventHandler != null)
795 _statusChangedEventHandler(this, e);
799 private void OnResized(int resized)
801 ResizedEventArgs e = new ResizedEventArgs();
804 if (_resizedEventHandler != null)
806 _resizedEventHandler(this, e);
810 private void OnLanguageChanged(int languageChanged)
812 LanguageChangedEventArgs e = new LanguageChangedEventArgs();
813 e.LanguageChanged = languageChanged;
815 if (_languageChangedEventHandler != null)
817 _languageChangedEventHandler(this, e);
821 private void OnKeyboardTypeChanged(KeyboardType type)
823 KeyboardTypeChangedEventArgs e = new KeyboardTypeChangedEventArgs();
825 e.KeyboardType = type;
827 if (_keyboardTypeChangedEventHandler != null)
829 _keyboardTypeChangedEventHandler(this, e);
834 /// This structure is used to pass on data from the IMF regarding predictive text.
836 /// <since_tizen> 5 </since_tizen>
837 public class EventData : global::System.IDisposable
840 /// The state if it owns memory
842 /// <since_tizen> 5 </since_tizen>
843 protected bool swigCMemOwn;
846 /// A flag to check if it is already disposed.
848 /// <since_tizen> 5 </since_tizen>
849 protected bool disposed = false;
851 private global::System.Runtime.InteropServices.HandleRef swigCPtr;
853 //A flag to check who called Dispose(). (By User or DisposeQueue)
854 private bool isDisposeQueued = false;
857 /// The default constructor.
859 /// <since_tizen> 5 </since_tizen>
860 public EventData() : this(NDalicManualPINVOKE.new_InputMethodContext_EventData__SWIG_0(), true)
862 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
868 /// <param name="aEventName">The name of the event from the IMF.</param>
869 /// <param name="aPredictiveString">The pre-edit or the commit string.</param>
870 /// <param name="aCursorOffset">Start the position from the current cursor position to start deleting characters.</param>
871 /// <param name="aNumberOfChars">The number of characters to delete from the cursorOffset.</param>
872 /// <since_tizen> 5 </since_tizen>
873 public EventData(InputMethodContext.EventType aEventName, string aPredictiveString, int aCursorOffset, int aNumberOfChars) : this(NDalicManualPINVOKE.new_InputMethodContext_EventData__SWIG_1((int)aEventName, aPredictiveString, aCursorOffset, aNumberOfChars), true)
875 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
878 internal EventData(IntPtr cPtr, bool cMemoryOwn)
880 swigCMemOwn = cMemoryOwn;
881 swigCPtr = new global::System.Runtime.InteropServices.HandleRef(this, cPtr);
885 /// Releases the resource.
887 /// <since_tizen> 5 </since_tizen>
890 if (!isDisposeQueued)
892 isDisposeQueued = true;
893 DisposeQueue.Instance.Add(this);
898 /// The pre-edit or the commit string.
900 /// <since_tizen> 5 </since_tizen>
901 public string PredictiveString
905 NDalicManualPINVOKE.InputMethodContext_EventData_predictiveString_set(swigCPtr, value);
906 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
910 string ret = NDalicManualPINVOKE.InputMethodContext_EventData_predictiveString_get(swigCPtr);
911 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
917 /// The name of the event from the IMF.
919 /// <since_tizen> 5 </since_tizen>
920 public InputMethodContext.EventType EventName
924 NDalicManualPINVOKE.InputMethodContext_EventData_eventName_set(swigCPtr, (int)value);
925 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
929 InputMethodContext.EventType ret = (InputMethodContext.EventType)NDalicManualPINVOKE.InputMethodContext_EventData_eventName_get(swigCPtr);
930 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
936 /// The start position from the current cursor position to start deleting characters.
938 /// <since_tizen> 5 </since_tizen>
939 public int CursorOffset
943 NDalicManualPINVOKE.InputMethodContext_EventData_cursorOffset_set(swigCPtr, value);
944 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
948 int ret = NDalicManualPINVOKE.InputMethodContext_EventData_cursorOffset_get(swigCPtr);
949 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
955 /// The number of characters to delete from the cursorOffset.
957 /// <since_tizen> 5 </since_tizen>
958 public int NumberOfChars
962 NDalicManualPINVOKE.InputMethodContext_EventData_numberOfChars_set(swigCPtr, value);
963 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
967 int ret = NDalicManualPINVOKE.InputMethodContext_EventData_numberOfChars_get(swigCPtr);
968 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
974 /// The dispose pattern.
976 /// <since_tizen> 5 </since_tizen>
977 public void Dispose()
979 //Throw excpetion if Dispose() is called in separate thread.
980 if (!Window.IsInstalled())
982 throw new System.InvalidOperationException("This API called from separate thread. This API must be called from MainThread.");
987 Dispose(DisposeTypes.Implicit);
991 Dispose(DisposeTypes.Explicit);
992 System.GC.SuppressFinalize(this);
996 internal static global::System.Runtime.InteropServices.HandleRef getCPtr(EventData obj)
998 return (obj == null) ? new global::System.Runtime.InteropServices.HandleRef(null, IntPtr.Zero) : obj.swigCPtr;
1001 internal static EventData GetEventDataFromPtr(IntPtr cPtr)
1003 EventData ret = new EventData(cPtr, false);
1004 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1009 /// You can override it to clean-up your own resources.
1011 /// <since_tizen> 5 </since_tizen>
1012 protected virtual void Dispose(DisposeTypes type)
1019 if (type == DisposeTypes.Explicit)
1022 //Release your own managed resources here.
1023 //You should release all of your own disposable objects here.
1027 //Release your own unmanaged resources here.
1028 //You should not access any managed member here except static instance.
1029 //because the execution order of Finalizes is non-deterministic.
1031 if (swigCPtr.Handle != IntPtr.Zero)
1035 swigCMemOwn = false;
1036 NDalicManualPINVOKE.delete_InputMethodContext_EventData(swigCPtr);
1038 swigCPtr = new global::System.Runtime.InteropServices.HandleRef(null, IntPtr.Zero);
1046 /// Data required by the IMF from the callback.
1048 /// <since_tizen> 5 </since_tizen>
1049 public class CallbackData : global::System.IDisposable
1052 /// The state if it owns memory
1054 /// <since_tizen> 5 </since_tizen>
1055 protected bool swigCMemOwn;
1058 /// A Flag to check if it is already disposed.
1060 /// <since_tizen> 5 </since_tizen>
1061 protected bool disposed = false;
1063 private global::System.Runtime.InteropServices.HandleRef swigCPtr;
1065 //A flag to check who called Dispose(). (By User or DisposeQueue)
1066 private bool isDisposeQueued = false;
1069 /// The default constructor.
1071 /// <since_tizen> 5 </since_tizen>
1072 public CallbackData() : this(NDalicManualPINVOKE.new_InputMethodContext_CallbackData__SWIG_0(), true)
1074 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1078 /// The constructor.
1080 /// <param name="aUpdate">True if the cursor position needs to be updated.</param>
1081 /// <param name="aCursorPosition">The new position of the cursor.</param>
1082 /// <param name="aCurrentText">The current text string.</param>
1083 /// <param name="aPreeditResetRequired">Flag if preedit reset is required.</param>
1084 /// <since_tizen> 5 </since_tizen>
1085 public CallbackData(bool aUpdate, int aCursorPosition, string aCurrentText, bool aPreeditResetRequired) : this(NDalicManualPINVOKE.new_InputMethodContext_CallbackData__SWIG_1(aUpdate, aCursorPosition, aCurrentText, aPreeditResetRequired), true)
1087 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1091 /// Releases the resource.
1093 /// <since_tizen> 5 </since_tizen>
1096 if (!isDisposeQueued)
1098 isDisposeQueued = true;
1099 DisposeQueue.Instance.Add(this);
1104 /// The current text string.
1106 /// <since_tizen> 5 </since_tizen>
1107 public string CurrentText
1111 NDalicManualPINVOKE.InputMethodContext_CallbackData_currentText_set(swigCPtr, value);
1112 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1116 string ret = NDalicManualPINVOKE.InputMethodContext_CallbackData_currentText_get(swigCPtr);
1117 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1123 /// The current cursor position.
1125 /// <since_tizen> 5 </since_tizen>
1126 public int CursorPosition
1130 NDalicManualPINVOKE.InputMethodContext_CallbackData_cursorPosition_set(swigCPtr, value);
1131 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1135 int ret = NDalicManualPINVOKE.InputMethodContext_CallbackData_cursorPosition_get(swigCPtr);
1136 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1142 /// The state if the cursor position needs to be updated.
1144 /// <since_tizen> 5 </since_tizen>
1149 NDalicManualPINVOKE.InputMethodContext_CallbackData_update_set(swigCPtr, value);
1150 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1154 bool ret = NDalicManualPINVOKE.InputMethodContext_CallbackData_update_get(swigCPtr);
1155 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1161 /// Flags if the pre-edit reset is required.
1163 /// <since_tizen> 5 </since_tizen>
1164 public bool PreeditResetRequired
1168 NDalicManualPINVOKE.InputMethodContext_CallbackData_preeditResetRequired_set(swigCPtr, value);
1169 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1173 bool ret = NDalicManualPINVOKE.InputMethodContext_CallbackData_preeditResetRequired_get(swigCPtr);
1174 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1180 /// The dispose pattern.
1182 /// <since_tizen> 5 </since_tizen>
1183 public void Dispose()
1185 //Throw excpetion if Dispose() is called in separate thread.
1186 if (!Window.IsInstalled())
1188 throw new System.InvalidOperationException("This API called from separate thread. This API must be called from MainThread.");
1191 if (isDisposeQueued)
1193 Dispose(DisposeTypes.Implicit);
1197 Dispose(DisposeTypes.Explicit);
1198 System.GC.SuppressFinalize(this);
1202 internal IntPtr GetCallbackDataPtr()
1204 return (IntPtr)swigCPtr;
1207 internal CallbackData(IntPtr cPtr, bool cMemoryOwn)
1209 swigCMemOwn = cMemoryOwn;
1210 swigCPtr = new global::System.Runtime.InteropServices.HandleRef(this, cPtr);
1213 internal static global::System.Runtime.InteropServices.HandleRef getCPtr(CallbackData obj)
1215 return (obj == null) ? new global::System.Runtime.InteropServices.HandleRef(null, IntPtr.Zero) : obj.swigCPtr;
1218 internal static CallbackData GetCallbackDataFromPtr(IntPtr cPtr)
1220 CallbackData ret = new CallbackData(cPtr, false);
1221 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1226 /// You can override it to clean-up your own resources.
1228 /// <since_tizen> 5 </since_tizen>
1229 protected virtual void Dispose(DisposeTypes type)
1236 if (type == DisposeTypes.Explicit)
1239 //Release your own managed resources here.
1240 //You should release all of your own disposable objects here.
1244 //Release your own unmanaged resources here.
1245 //You should not access any managed member here except static instance.
1246 //Because the execution order of Finalizes is non-deterministic.
1248 if (swigCPtr.Handle != IntPtr.Zero)
1252 swigCMemOwn = false;
1253 NDalicManualPINVOKE.delete_InputMethodContext_CallbackData(swigCPtr);
1255 swigCPtr = new global::System.Runtime.InteropServices.HandleRef(null, IntPtr.Zero);
1263 /// InputMethodContext activated event arguments.
1265 /// <since_tizen> 5 </since_tizen>
1266 public class ActivatedEventArgs : EventArgs
1269 /// The instance of InputMethodContext
1271 /// <since_tizen> 5 </since_tizen>
1272 public InputMethodContext InputMethodContext
1280 /// InputMethodContext event receives event arguments.
1282 /// <since_tizen> 5 </since_tizen>
1283 public class EventReceivedEventArgs : EventArgs
1286 /// The instance of InputMethodContext
1288 /// <since_tizen> 5 </since_tizen>
1289 public InputMethodContext InputMethodContext
1296 /// The event data of IMF
1298 /// <since_tizen> 5 </since_tizen>
1299 public EventData EventData
1307 /// InputMethodContext status changed event arguments.
1309 /// <since_tizen> 5 </since_tizen>
1310 public class StatusChangedEventArgs : EventArgs
1313 /// InputMethodContext status.
1315 /// <since_tizen> 5 </since_tizen>
1316 public bool StatusChanged
1324 /// InputMethodContext resized event arguments.
1326 /// <since_tizen> 5 </since_tizen>
1327 public class ResizedEventArgs : EventArgs
1330 /// The state if the IMF resized.
1332 /// <since_tizen> 5 </since_tizen>
1341 /// InputMethodContext language changed event arguments.
1343 /// <since_tizen> 5 </since_tizen>
1344 public class LanguageChangedEventArgs : EventArgs
1347 /// Language changed.
1349 /// <since_tizen> 5 </since_tizen>
1350 public int LanguageChanged
1358 /// InputMethodContext keyboard type changed event arguments.
1360 /// <since_tizen> 5 </since_tizen>
1361 public class KeyboardTypeChangedEventArgs : EventArgs
1364 /// InputMethodContext keyboard type.
1366 /// <since_tizen> 5 </since_tizen>
1367 public KeyboardType KeyboardType