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
31 private ActivatedEventCallbackType _activatedEventCallback;
32 private EventReceivedEventCallbackType _eventReceivedEventCallback;
33 private StatusChangedEventCallbackType _statusChangedEventCallback;
34 private ResizedEventCallbackType _resizedEventCallback;
35 private LanguageChangedEventCallbackType _languageChangedEventCallback;
36 private KeyboardTypeChangedEventCallbackType _keyboardTypeChangedEventCallback;
37 private ContentReceivedCallbackType _contentReceivedEventCallback;
42 /// <since_tizen> 5 </since_tizen>
43 /// This will be deprecated
44 [Obsolete("Deprecated in API8; Will be removed in API10")]
45 public InputMethodContext() : this(Interop.InputMethodContext.New(), true)
47 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
51 internal InputMethodContext(IntPtr cPtr, bool cMemoryOwn) : base(Interop.InputMethodContext.Upcast(cPtr), cMemoryOwn)
55 [UnmanagedFunctionPointer(CallingConvention.StdCall)]
56 private delegate void ActivatedEventCallbackType(IntPtr data);
57 private delegate IntPtr EventReceivedEventCallbackType(IntPtr inputMethodContext, IntPtr eventData);
58 private delegate void StatusChangedEventCallbackType(bool statusChanged);
59 private delegate void ResizedEventCallbackType(int resized);
60 private delegate void LanguageChangedEventCallbackType(int languageChanged);
61 private delegate void KeyboardTypeChangedEventCallbackType(KeyboardType type);
62 private delegate void ContentReceivedCallbackType(string content, string description, string mimeType);
64 private event EventHandler<ActivatedEventArgs> _activatedEventHandler;
65 private event EventHandlerWithReturnType<object, EventReceivedEventArgs, CallbackData> _eventReceivedEventHandler;
66 private event EventHandler<StatusChangedEventArgs> _statusChangedEventHandler;
67 private event EventHandler<ResizedEventArgs> _resizedEventHandler;
68 private event EventHandler<LanguageChangedEventArgs> _languageChangedEventHandler;
69 private event EventHandler<KeyboardTypeChangedEventArgs> _keyboardTypeChangedEventHandler;
70 private event EventHandler<ContentReceivedEventArgs> _contentReceivedEventHandler;
73 /// InputMethodContext activated.
75 /// <since_tizen> 5 </since_tizen>
76 public event EventHandler<ActivatedEventArgs> Activated
80 if (_activatedEventHandler == null)
82 _activatedEventCallback = OnActivated;
83 ActivatedSignal().Connect(_activatedEventCallback);
86 _activatedEventHandler += value;
90 _activatedEventHandler -= value;
92 if (_activatedEventHandler == null && _activatedEventCallback != null)
94 ActivatedSignal().Disconnect(_activatedEventCallback);
100 /// InputMethodContext event received.
102 /// <since_tizen> 5 </since_tizen>
103 public event EventHandlerWithReturnType<object, EventReceivedEventArgs, CallbackData> EventReceived
107 if (_eventReceivedEventHandler == null)
109 _eventReceivedEventCallback = OnEventReceived;
110 EventReceivedSignal().Connect(_eventReceivedEventCallback);
113 _eventReceivedEventHandler += value;
117 _eventReceivedEventHandler -= value;
119 if (_eventReceivedEventHandler == null && _eventReceivedEventCallback != null)
121 EventReceivedSignal().Disconnect(_eventReceivedEventCallback);
127 /// InputMethodContext status changed.
129 /// <since_tizen> 5 </since_tizen>
130 public event EventHandler<StatusChangedEventArgs> StatusChanged
134 if (_statusChangedEventHandler == null)
136 _statusChangedEventCallback = OnStatusChanged;
137 StatusChangedSignal().Connect(_statusChangedEventCallback);
140 _statusChangedEventHandler += value;
144 _statusChangedEventHandler -= value;
146 if (_statusChangedEventHandler == null && _statusChangedEventCallback != null)
148 StatusChangedSignal().Disconnect(_statusChangedEventCallback);
154 /// InputMethodContext resized.
156 /// <since_tizen> 5 </since_tizen>
157 public event EventHandler<ResizedEventArgs> Resized
161 if (_resizedEventHandler == null)
163 _resizedEventCallback = OnResized;
164 ResizedSignal().Connect(_resizedEventCallback);
167 _resizedEventHandler += value;
171 _resizedEventHandler -= value;
173 if (_resizedEventHandler == null && _resizedEventCallback != null)
175 ResizedSignal().Disconnect(_resizedEventCallback);
181 /// InputMethodContext language changed.
183 /// <since_tizen> 5 </since_tizen>
184 public event EventHandler<LanguageChangedEventArgs> LanguageChanged
188 if (_languageChangedEventHandler == null)
190 _languageChangedEventCallback = OnLanguageChanged;
191 LanguageChangedSignal().Connect(_languageChangedEventCallback);
194 _languageChangedEventHandler += value;
198 _languageChangedEventHandler -= value;
200 if (_languageChangedEventHandler == null && _languageChangedEventCallback != null)
202 LanguageChangedSignal().Disconnect(_languageChangedEventCallback);
208 /// InputMethodContext keyboard type changed.
210 /// <since_tizen> 5 </since_tizen>
211 public event EventHandler<KeyboardTypeChangedEventArgs> KeyboardTypeChanged
215 if (_keyboardTypeChangedEventHandler == null)
217 _keyboardTypeChangedEventCallback = OnKeyboardTypeChanged;
218 KeyboardTypeChangedSignal().Connect(_keyboardTypeChangedEventCallback);
221 _keyboardTypeChangedEventHandler += value;
225 _keyboardTypeChangedEventHandler -= value;
227 if (_keyboardTypeChangedEventHandler == null && _keyboardTypeChangedEventCallback != null)
229 KeyboardTypeChangedSignal().Disconnect(_keyboardTypeChangedEventCallback);
235 /// InputMethodContext content received.
237 /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
238 [EditorBrowsable(EditorBrowsableState.Never)]
239 public event EventHandler<ContentReceivedEventArgs> ContentReceived
243 if (_contentReceivedEventHandler == null)
245 _contentReceivedEventCallback = OnContentReceived;
246 ContentReceivedSignal().Connect(_contentReceivedEventCallback);
249 _contentReceivedEventHandler += value;
253 _contentReceivedEventHandler -= value;
255 if (_contentReceivedEventHandler == null && _contentReceivedEventCallback != null)
257 ContentReceivedSignal().Disconnect(_contentReceivedEventCallback);
263 /// The direction of the text.
265 /// <since_tizen> 5 </since_tizen>
266 public enum TextDirection
279 /// Events that are generated by the IMF.
281 /// <since_tizen> 5 </since_tizen>
282 public enum EventType
287 /// <since_tizen> 5 </since_tizen>
290 /// Pre-edit changed.
292 /// <since_tizen> 5 </since_tizen>
297 /// <since_tizen> 5 </since_tizen>
300 /// An event to delete a range of characters from the string.
302 /// <since_tizen> 5 </since_tizen>
305 /// An event to query string and the cursor position.
307 /// <since_tizen> 5 </since_tizen>
310 /// Private command sent from the input panel.
312 /// <since_tizen> 5 </since_tizen>
317 /// Enumeration for the state of the input panel.
319 /// <since_tizen> 5 </since_tizen>
325 /// <since_tizen> 5 </since_tizen>
328 /// Input panel is shown.
330 /// <since_tizen> 5 </since_tizen>
333 /// Input panel is hidden.
335 /// <since_tizen> 5 </since_tizen>
338 /// Input panel in process of being shown.
340 /// <since_tizen> 5 </since_tizen>
345 /// Enumeration for the types of keyboard.
347 /// <since_tizen> 5 </since_tizen>
348 public enum KeyboardType
351 /// Software keyboard (virtual keyboard) is default.
353 /// <since_tizen> 5 </since_tizen>
356 /// Hardware keyboard.
358 /// <since_tizen> 5 </since_tizen>
363 /// Enumeration for the language mode of the input panel.
365 /// <since_tizen> 8 </since_tizen>
366 public enum InputPanelLanguage
369 /// IME Language is automatically set depending on the system display.
371 /// <since_tizen> 8 </since_tizen>
374 /// Latin alphabet at all times.
376 /// <since_tizen> 8 </since_tizen>
381 /// Gets or sets whether the IM context allows to use the text prediction.
383 /// <since_tizen> 8 </since_tizen>
384 public bool TextPrediction
388 return IsTextPredictionAllowed();
392 AllowTextPrediction(value);
397 /// Destroys the context of the IMF.<br/>
399 /// <since_tizen> 5 </since_tizen>
400 public void DestroyContext()
402 Interop.InputMethodContext.Finalize(swigCPtr);
403 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
407 /// Activates the IMF.<br/>
408 /// It means that the text editing has started.<br/>
409 /// If the hardware keyboard is not connected, then it shows the virtual keyboard.
411 /// <since_tizen> 5 </since_tizen>
412 public void Activate()
414 Interop.InputMethodContext.Activate(swigCPtr);
415 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
419 /// Deactivates the IMF.<br/>
420 /// It means that the text editing is complete.
422 /// <since_tizen> 5 </since_tizen>
423 public void Deactivate()
425 Interop.InputMethodContext.Deactivate(swigCPtr);
426 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
430 /// Gets the restoration status, which controls if the keyboard is restored after the focus is lost and then regained.<br/>
431 /// If true, then the keyboard will be restored (activated) after the focus is regained.
433 /// <returns>The restoration status.</returns>
434 /// <since_tizen> 5 </since_tizen>
435 public bool RestoreAfterFocusLost()
437 bool ret = Interop.InputMethodContext.RestoreAfterFocusLost(swigCPtr);
438 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
443 /// Sets the status whether the IMF has to restore the keyboard after losing focus.
445 /// <param name="toggle">True means that keyboard must be restored after the focus is lost and regained.</param>
446 /// <since_tizen> 5 </since_tizen>
447 public void SetRestoreAfterFocusLost(bool toggle)
449 Interop.InputMethodContext.SetRestoreAfterFocusLost(swigCPtr, toggle);
450 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
454 /// Sends a message reset to the pre-edit state or the IMF module.
456 /// <since_tizen> 5 </since_tizen>
457 public new void Reset()
459 Interop.InputMethodContext.Reset(swigCPtr);
460 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
464 /// Notifies the IMF context that the cursor position has changed, required for features such as auto-capitalization.
466 /// <since_tizen> 5 </since_tizen>
467 public void NotifyCursorPosition()
469 Interop.InputMethodContext.NotifyCursorPosition(swigCPtr);
470 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
474 /// Sets the cursor position stored in VirtualKeyboard, this is required by the IMF context.
476 /// <param name="cursorPosition">The position of the cursor.</param>
477 /// <since_tizen> 5 </since_tizen>
478 public void SetCursorPosition(uint cursorPosition)
480 Interop.InputMethodContext.SetCursorPosition(swigCPtr, cursorPosition);
481 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
485 /// Gets the cursor position stored in VirtualKeyboard, this is required by the IMF context.
487 /// <returns>The current position of the cursor.</returns>
488 /// <since_tizen> 5 </since_tizen>
489 public uint GetCursorPosition()
491 uint ret = Interop.InputMethodContext.GetCursorPosition(swigCPtr);
492 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
497 /// A method to store the string required by the IMF, this is used to provide predictive word suggestions.
499 /// <param name="text">The text string surrounding the current cursor point.</param>
500 /// <since_tizen> 5 </since_tizen>
501 public void SetSurroundingText(string text)
503 Interop.InputMethodContext.SetSurroundingText(swigCPtr, text);
504 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
508 /// Gets the current text string set within the IMF manager, this is used to offer predictive suggestions.
510 /// <returns>The surrounding text.</returns>
511 /// <since_tizen> 5 </since_tizen>
512 public string GetSurroundingText()
514 string ret = Interop.InputMethodContext.GetSurroundingText(swigCPtr);
515 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
520 /// Notifies the IMF context that text input is set to multiline or not.
522 /// <param name="multiLine">True if multiline text input is used.</param>
523 /// <since_tizen> 5 </since_tizen>
524 public void NotifyTextInputMultiLine(bool multiLine)
526 Interop.InputMethodContext.NotifyTextInputMultiLine(swigCPtr, multiLine);
527 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
531 /// Returns the text direction of the current input language of the keyboard.
533 /// <returns>The direction of the text.</returns>
534 /// <since_tizen> 5 </since_tizen>
535 public InputMethodContext.TextDirection GetTextDirection()
537 InputMethodContext.TextDirection ret = (InputMethodContext.TextDirection)Interop.InputMethodContext.GetTextDirection(swigCPtr);
538 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
543 /// Provides the size and the position of the keyboard.<br/>
544 /// The position is relative to whether the keyboard is visible or not.<br/>
545 /// If the keyboard is not visible, then the position will be off the screen.<br/>
546 /// If the keyboard is not being shown when this method is called, the keyboard is partially setup (IMFContext) to get/>
547 /// the values then taken down. So ideally, GetInputMethodArea() must be called after Show().
549 /// <returns>Rectangle which is keyboard panel x, y, width, and height.</returns>
550 /// <since_tizen> 5 </since_tizen>
551 public Rectangle GetInputMethodArea()
553 Rectangle ret = new Rectangle(Interop.InputMethodContext.GetInputMethodArea(swigCPtr), true);
554 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
559 /// Sets up the input panel specific data.
561 /// <param name="text">The specific data to be set to the input panel.</param>
562 /// <since_tizen> 5 </since_tizen>
563 public void SetInputPanelUserData(string text)
565 Interop.InputMethodContext.SetInputPanelUserData(swigCPtr, text);
566 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
570 /// Gets the specific data of the current active input panel.
572 /// <param name="text">The specific data to be received from the input panel.</param>
573 /// <since_tizen> 5 </since_tizen>
574 public void GetInputPanelUserData(out string text)
576 Interop.InputMethodContext.GetInputPanelUserData(swigCPtr, out text);
577 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
581 /// Gets the state of the current active input panel.
583 /// <returns>The state of the input panel.</returns>
584 /// <since_tizen> 5 </since_tizen>
585 public InputMethodContext.State GetInputPanelState()
587 InputMethodContext.State ret = (InputMethodContext.State)Interop.InputMethodContext.GetInputPanelState(swigCPtr);
588 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
593 /// Sets the return key on the input panel to be visible or invisible.<br/>
594 /// The default value is true.
596 /// <param name="visible">True if the return key is visible (enabled), false otherwise.</param>
597 /// <since_tizen> 5 </since_tizen>
598 public void SetReturnKeyState(bool visible)
600 Interop.InputMethodContext.SetReturnKeyState(swigCPtr, visible);
601 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
605 /// Enables to show the input panel automatically when focused.
607 /// <param name="enabled">If true, the input panel will be shown when focused.</param>
608 /// <since_tizen> 5 </since_tizen>
609 public void AutoEnableInputPanel(bool enabled)
611 Interop.InputMethodContext.AutoEnableInputPanel(swigCPtr, enabled);
612 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
616 /// Shows the input panel.
618 /// <since_tizen> 5 </since_tizen>
619 public void ShowInputPanel()
621 Interop.InputMethodContext.ShowInputPanel(swigCPtr);
622 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
626 /// Hides the input panel.
628 /// <since_tizen> 5 </since_tizen>
629 public void HideInputPanel()
631 Interop.InputMethodContext.HideInputPanel(swigCPtr);
632 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
636 /// Gets the keyboard type.<br/>
637 /// The default keyboard type is SoftwareKeyboard.
639 /// <returns>The keyboard type.</returns>
640 /// <since_tizen> 5 </since_tizen>
641 public InputMethodContext.KeyboardType GetKeyboardType()
643 InputMethodContext.KeyboardType ret = (InputMethodContext.KeyboardType)Interop.InputMethodContext.GetKeyboardType(swigCPtr);
644 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
649 /// Gets the current language locale of the input panel.<br/>
650 /// For example, en_US, en_GB, en_PH, fr_FR, and so on.
652 /// <returns>The current language locale of the input panel.</returns>
653 /// <since_tizen> 5 </since_tizen>
654 public string GetInputPanelLocale()
656 string ret = Interop.InputMethodContext.GetInputPanelLocale(swigCPtr);
657 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
662 /// Sets the allowed MIME Type to deliver to the input panel. <br/>
663 /// For example, string mimeType = "text/plain,image/png,image/gif,application/pdf";
665 /// <param name="mimeType">The allowed MIME type.</param>
666 /// <since_tizen> 8 </since_tizen>
667 public void SetMIMEType(string mimeType)
669 Interop.InputMethodContext.SetMIMEType(swigCPtr, mimeType);
670 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
674 /// Sets the x,y coordinates of the input panel.
676 /// <param name="x">The top-left x coordinate of the input panel.</param>
677 /// <param name="y">The top-left y coordinate of the input panel.</param>
678 /// <since_tizen> 8 </since_tizen>
679 public void SetInputPanelPosition(uint x, uint y)
681 Interop.InputMethodContext.SetInputPanelPosition(swigCPtr, x, y);
682 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
686 /// Sets the language of the input panel.
688 /// <param name="language">The language to be set to the input panel</param>
689 /// <since_tizen> 8 </since_tizen>
690 public void SetInputPanelLanguage(InputMethodContext.InputPanelLanguage language)
692 Interop.InputMethodContext.SetInputPanelLanguage(swigCPtr, (int)language);
693 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
697 /// Gets the language of the input panel.
699 /// <returns>The language of the input panel</returns>
700 /// <since_tizen> 8 </since_tizen>
701 public InputMethodContext.InputPanelLanguage GetInputPanelLanguage()
703 InputMethodContext.InputPanelLanguage ret = (InputMethodContext.InputPanelLanguage)Interop.InputMethodContext.GetInputPanelLanguage(swigCPtr);
704 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
708 internal static global::System.Runtime.InteropServices.HandleRef getCPtr(InputMethodContext obj)
710 return (obj == null) ? new global::System.Runtime.InteropServices.HandleRef(null, IntPtr.Zero) : obj.swigCPtr;
713 internal InputMethodContext(InputMethodContext inputMethodContext) : this(Interop.InputMethodContext.NewInputMethodContext(InputMethodContext.getCPtr(inputMethodContext)), true)
715 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
718 internal InputMethodContext Assign(InputMethodContext inputMethodContext)
720 InputMethodContext ret = new InputMethodContext(Interop.InputMethodContext.Assign(swigCPtr, InputMethodContext.getCPtr(inputMethodContext)), false);
721 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
725 internal static InputMethodContext DownCast(BaseHandle handle)
727 InputMethodContext ret = new InputMethodContext(Interop.InputMethodContext.DownCast(BaseHandle.getCPtr(handle)), true);
728 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
732 internal void ApplyOptions(InputMethodOptions options)
734 Interop.InputMethodContext.ApplyOptions(swigCPtr, InputMethodOptions.getCPtr(options));
735 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
738 internal void AllowTextPrediction(bool prediction)
740 Interop.InputMethodContext.AllowTextPrediction(swigCPtr, prediction);
741 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
744 internal bool IsTextPredictionAllowed()
746 bool ret = Interop.InputMethodContext.IsTextPredictionAllowed(swigCPtr);
747 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
751 internal ActivatedSignalType ActivatedSignal()
753 ActivatedSignalType ret = new ActivatedSignalType(Interop.InputMethodContext.ActivatedSignal(swigCPtr), false);
754 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
758 internal KeyboardEventSignalType EventReceivedSignal()
760 KeyboardEventSignalType ret = new KeyboardEventSignalType(Interop.InputMethodContext.EventReceivedSignal(swigCPtr), false);
761 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
765 internal StatusSignalType StatusChangedSignal()
767 StatusSignalType ret = new StatusSignalType(Interop.InputMethodContext.StatusChangedSignal(swigCPtr), false);
768 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
772 internal KeyboardResizedSignalType ResizedSignal()
774 KeyboardResizedSignalType ret = new KeyboardResizedSignalType(Interop.InputMethodContext.ResizedSignal(swigCPtr), false);
775 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
779 internal LanguageChangedSignalType LanguageChangedSignal()
781 LanguageChangedSignalType ret = new LanguageChangedSignalType(Interop.InputMethodContext.LanguageChangedSignal(swigCPtr), false);
782 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
786 internal KeyboardTypeSignalType KeyboardTypeChangedSignal()
788 KeyboardTypeSignalType ret = new KeyboardTypeSignalType(Interop.InputMethodContext.KeyboardTypeChangedSignal(swigCPtr), false);
789 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
793 internal ContentReceivedSignalType ContentReceivedSignal()
795 ContentReceivedSignalType ret = new ContentReceivedSignalType(Interop.InputMethodContext.ContentReceivedSignal(swigCPtr), false);
796 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
801 /// You can override it to clean-up your own resources.
803 /// <param name="type">Dispose Type</param>
804 /// <since_tizen> 5 </since_tizen>
805 /// Please do not use! This will be deprecated!
806 /// Dispose() method in Singletone classes (ex: FocusManager, StyleManager, VisualFactory, InputMethodContext, TtsPlayer, Window) is not required.
807 [EditorBrowsable(EditorBrowsableState.Never)]
808 protected override void Dispose(DisposeTypes type)
815 //Release your own unmanaged resources here.
816 //You should not access any managed member here except static instance
817 //because the execution order of Finalizes is non-deterministic.
819 if (_keyboardTypeChangedEventCallback != null)
821 KeyboardTypeChangedSignal().Disconnect(_keyboardTypeChangedEventCallback);
827 /// This will not be public opened.
828 [EditorBrowsable(EditorBrowsableState.Never)]
829 protected override void ReleaseSwigCPtr(System.Runtime.InteropServices.HandleRef swigCPtr)
831 Interop.InputMethodContext.DeleteInputMethodContext(swigCPtr);
834 private void OnActivated(IntPtr data)
836 ActivatedEventArgs e = new ActivatedEventArgs();
840 e.InputMethodContext = Registry.GetManagedBaseHandleFromNativePtr(data) as InputMethodContext;
843 if (_activatedEventHandler != null)
845 _activatedEventHandler(this, e);
849 private IntPtr OnEventReceived(IntPtr inputMethodContext, IntPtr eventData)
851 CallbackData callbackData = null;
853 EventReceivedEventArgs e = new EventReceivedEventArgs();
855 if (inputMethodContext != null)
857 e.InputMethodContext = Registry.GetManagedBaseHandleFromNativePtr(inputMethodContext) as InputMethodContext;
859 if (eventData != null)
861 e.EventData = EventData.GetEventDataFromPtr(eventData);
864 if (_eventReceivedEventHandler != null)
866 callbackData = _eventReceivedEventHandler(this, e);
868 if (callbackData != null)
870 return callbackData.GetCallbackDataPtr();
874 return new CallbackData().GetCallbackDataPtr();
878 private void OnStatusChanged(bool statusChanged)
880 StatusChangedEventArgs e = new StatusChangedEventArgs();
882 e.StatusChanged = statusChanged;
884 if (_statusChangedEventHandler != null)
886 _statusChangedEventHandler(this, e);
890 private void OnResized(int resized)
892 ResizedEventArgs e = new ResizedEventArgs();
895 if (_resizedEventHandler != null)
897 _resizedEventHandler(this, e);
901 private void OnLanguageChanged(int languageChanged)
903 LanguageChangedEventArgs e = new LanguageChangedEventArgs();
904 e.LanguageChanged = languageChanged;
906 if (_languageChangedEventHandler != null)
908 _languageChangedEventHandler(this, e);
912 private void OnKeyboardTypeChanged(KeyboardType type)
914 KeyboardTypeChangedEventArgs e = new KeyboardTypeChangedEventArgs();
916 e.KeyboardType = type;
918 if (_keyboardTypeChangedEventHandler != null)
920 _keyboardTypeChangedEventHandler(this, e);
924 private void OnContentReceived(string content, string description, string mimeType)
926 ContentReceivedEventArgs e = new ContentReceivedEventArgs();
928 e.Description = description;
929 e.MimeType = mimeType;
931 if (_contentReceivedEventHandler != null)
933 _contentReceivedEventHandler(this, e);
938 /// This structure is used to pass on data from the IMF regarding predictive text.
940 /// <since_tizen> 5 </since_tizen>
941 public class EventData : Disposable
944 /// The state if it owns memory
946 /// <since_tizen> 5 </since_tizen>
947 protected bool swigCMemOwn;
948 private global::System.Runtime.InteropServices.HandleRef swigCPtr;
951 /// The default constructor.
953 /// <since_tizen> 5 </since_tizen>
954 public EventData() : this(Interop.InputMethodContext.NewInputMethodContextEventData(), true)
956 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
962 /// <param name="aEventName">The name of the event from the IMF.</param>
963 /// <param name="aPredictiveString">The pre-edit or the commit string.</param>
964 /// <param name="aCursorOffset">Start the position from the current cursor position to start deleting characters.</param>
965 /// <param name="aNumberOfChars">The number of characters to delete from the cursorOffset.</param>
966 /// <since_tizen> 5 </since_tizen>
967 public EventData(InputMethodContext.EventType aEventName, string aPredictiveString, int aCursorOffset, int aNumberOfChars) : this(Interop.InputMethodContext.NewInputMethodContextEventData((int)aEventName, aPredictiveString, aCursorOffset, aNumberOfChars), true)
969 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
972 internal EventData(IntPtr cPtr, bool cMemoryOwn)
974 swigCMemOwn = cMemoryOwn;
975 swigCPtr = new global::System.Runtime.InteropServices.HandleRef(this, cPtr);
979 /// The pre-edit or the commit string.
981 /// <since_tizen> 5 </since_tizen>
982 public string PredictiveString
986 Interop.InputMethodContext.EventDataPredictiveStringSet(swigCPtr, value);
987 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
991 string ret = Interop.InputMethodContext.EventDataPredictiveStringGet(swigCPtr);
992 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
998 /// The name of the event from the IMF.
1000 /// <since_tizen> 5 </since_tizen>
1001 public InputMethodContext.EventType EventName
1005 Interop.InputMethodContext.EventDataEventNameSet(swigCPtr, (int)value);
1006 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1010 InputMethodContext.EventType ret = (InputMethodContext.EventType)Interop.InputMethodContext.EventDataEventNameGet(swigCPtr);
1011 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1017 /// The start position from the current cursor position to start deleting characters.
1019 /// <since_tizen> 5 </since_tizen>
1020 public int CursorOffset
1024 Interop.InputMethodContext.EventDataCursorOffsetSet(swigCPtr, value);
1025 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1029 int ret = Interop.InputMethodContext.EventDataCursorOffsetGet(swigCPtr);
1030 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1036 /// The number of characters to delete from the cursorOffset.
1038 /// <since_tizen> 5 </since_tizen>
1039 public int NumberOfChars
1043 Interop.InputMethodContext.EventDataNumberOfCharsSet(swigCPtr, value);
1044 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1048 int ret = Interop.InputMethodContext.EventDataNumberOfCharsGet(swigCPtr);
1049 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1054 internal static global::System.Runtime.InteropServices.HandleRef getCPtr(EventData obj)
1056 return (obj == null) ? new global::System.Runtime.InteropServices.HandleRef(null, IntPtr.Zero) : obj.swigCPtr;
1059 internal static EventData GetEventDataFromPtr(IntPtr cPtr)
1061 EventData ret = new EventData(cPtr, false);
1062 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1067 /// You can override it to clean-up your own resources.
1069 /// <since_tizen> 5 </since_tizen>
1070 protected override void Dispose(DisposeTypes type)
1077 //Release your own unmanaged resources here.
1078 //You should not access any managed member here except static instance.
1079 //because the execution order of Finalizes is non-deterministic.
1081 if (swigCPtr.Handle != IntPtr.Zero)
1085 swigCMemOwn = false;
1086 Interop.InputMethodContext.DeleteInputMethodContextEventData(swigCPtr);
1088 swigCPtr = new global::System.Runtime.InteropServices.HandleRef(null, IntPtr.Zero);
1096 /// Data required by the IMF from the callback.
1098 /// <since_tizen> 5 </since_tizen>
1099 public class CallbackData : Disposable
1102 /// The state if it owns memory
1104 /// <since_tizen> 5 </since_tizen>
1105 protected bool swigCMemOwn;
1106 private global::System.Runtime.InteropServices.HandleRef swigCPtr;
1109 /// The default constructor.
1111 /// <since_tizen> 5 </since_tizen>
1112 public CallbackData() : this(Interop.InputMethodContext.NewInputMethodContextCallbackData(), true)
1114 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1118 /// The constructor.
1120 /// <param name="aUpdate">True if the cursor position needs to be updated.</param>
1121 /// <param name="aCursorPosition">The new position of the cursor.</param>
1122 /// <param name="aCurrentText">The current text string.</param>
1123 /// <param name="aPreeditResetRequired">Flag if preedit reset is required.</param>
1124 /// <since_tizen> 5 </since_tizen>
1125 public CallbackData(bool aUpdate, int aCursorPosition, string aCurrentText, bool aPreeditResetRequired) : this(Interop.InputMethodContext.NewInputMethodContextCallbackData(aUpdate, aCursorPosition, aCurrentText, aPreeditResetRequired), true)
1127 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1131 /// The current text string.
1133 /// <since_tizen> 5 </since_tizen>
1134 public string CurrentText
1138 Interop.InputMethodContext.CallbackDataCurrentTextSet(swigCPtr, value);
1139 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1143 string ret = Interop.InputMethodContext.CallbackDataCurrentTextGet(swigCPtr);
1144 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1150 /// The current cursor position.
1152 /// <since_tizen> 5 </since_tizen>
1153 public int CursorPosition
1157 Interop.InputMethodContext.CallbackDataCursorPositionSet(swigCPtr, value);
1158 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1162 int ret = Interop.InputMethodContext.CallbackDataCursorPositionGet(swigCPtr);
1163 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1169 /// The state if the cursor position needs to be updated.
1171 /// <since_tizen> 5 </since_tizen>
1176 Interop.InputMethodContext.CallbackDataUpdateSet(swigCPtr, value);
1177 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1181 bool ret = Interop.InputMethodContext.CallbackDataUpdateGet(swigCPtr);
1182 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1188 /// Flags if the pre-edit reset is required.
1190 /// <since_tizen> 5 </since_tizen>
1191 public bool PreeditResetRequired
1195 Interop.InputMethodContext.CallbackDataPreeditResetRequiredSet(swigCPtr, value);
1196 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1200 bool ret = Interop.InputMethodContext.CallbackDataPreeditResetRequiredGet(swigCPtr);
1201 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1206 internal IntPtr GetCallbackDataPtr()
1208 return (IntPtr)swigCPtr;
1211 internal CallbackData(IntPtr cPtr, bool cMemoryOwn)
1213 swigCMemOwn = cMemoryOwn;
1214 swigCPtr = new global::System.Runtime.InteropServices.HandleRef(this, cPtr);
1217 internal static CallbackData GetCallbackDataFromPtr(IntPtr cPtr)
1219 CallbackData ret = new CallbackData(cPtr, false);
1220 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1225 /// You can override it to clean-up your own resources.
1227 /// <since_tizen> 5 </since_tizen>
1228 protected override void Dispose(DisposeTypes type)
1235 //Release your own unmanaged resources here.
1236 //You should not access any managed member here except static instance.
1237 //Because the execution order of Finalizes is non-deterministic.
1239 if (swigCPtr.Handle != IntPtr.Zero)
1243 swigCMemOwn = false;
1244 Interop.InputMethodContext.DeleteInputMethodContextCallbackData(swigCPtr);
1246 swigCPtr = new global::System.Runtime.InteropServices.HandleRef(null, IntPtr.Zero);
1254 /// InputMethodContext activated event arguments.
1256 /// <since_tizen> 5 </since_tizen>
1257 public class ActivatedEventArgs : EventArgs
1260 /// The instance of InputMethodContext
1262 /// <since_tizen> 5 </since_tizen>
1263 public InputMethodContext InputMethodContext
1271 /// InputMethodContext event receives event arguments.
1273 /// <since_tizen> 5 </since_tizen>
1274 public class EventReceivedEventArgs : EventArgs
1277 /// The instance of InputMethodContext
1279 /// <since_tizen> 5 </since_tizen>
1280 public InputMethodContext InputMethodContext
1287 /// The event data of IMF
1289 /// <since_tizen> 5 </since_tizen>
1290 public EventData EventData
1298 /// InputMethodContext status changed event arguments.
1300 /// <since_tizen> 5 </since_tizen>
1301 public class StatusChangedEventArgs : EventArgs
1304 /// InputMethodContext status.
1306 /// <since_tizen> 5 </since_tizen>
1307 public bool StatusChanged
1315 /// InputMethodContext resized event arguments.
1317 /// <since_tizen> 5 </since_tizen>
1318 public class ResizedEventArgs : EventArgs
1321 /// The state if the IMF resized.
1323 /// <since_tizen> 5 </since_tizen>
1332 /// InputMethodContext language changed event arguments.
1334 /// <since_tizen> 5 </since_tizen>
1335 public class LanguageChangedEventArgs : EventArgs
1338 /// Language changed.
1340 /// <since_tizen> 5 </since_tizen>
1341 public int LanguageChanged
1349 /// InputMethodContext keyboard type changed event arguments.
1351 /// <since_tizen> 5 </since_tizen>
1352 public class KeyboardTypeChangedEventArgs : EventArgs
1355 /// InputMethodContext keyboard type.
1357 /// <since_tizen> 5 </since_tizen>
1358 public KeyboardType KeyboardType
1366 /// InputMethodContext content received event arguments.
1368 /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
1369 [EditorBrowsable(EditorBrowsableState.Never)]
1370 public class ContentReceivedEventArgs : EventArgs
1373 /// The content, such as images, of input method
1375 /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
1376 [EditorBrowsable(EditorBrowsableState.Never)]
1377 public string Content
1383 /// The description of content
1385 /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
1386 [EditorBrowsable(EditorBrowsableState.Never)]
1387 public string Description
1393 /// The mime type of content, such as jpg, png, and so on
1395 /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
1396 [EditorBrowsable(EditorBrowsableState.Never)]
1397 public string MimeType