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 //ToDo : raise ACR as [Obsolete("This has been deprecated in API9 and will be removed in API11. Please use swigCMemOwn which is declared in parent class")]
948 [System.Diagnostics.CodeAnalysis.SuppressMessage("Design", "CA1051:Do not declare visible instance fields", Justification = "<Pending>")]
949 protected bool swigCMemOwn;
950 private global::System.Runtime.InteropServices.HandleRef swigCPtr;
953 /// The default constructor.
955 /// <since_tizen> 5 </since_tizen>
956 public EventData() : this(Interop.InputMethodContext.NewInputMethodContextEventData(), true)
958 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
964 /// <param name="aEventName">The name of the event from the IMF.</param>
965 /// <param name="aPredictiveString">The pre-edit or the commit string.</param>
966 /// <param name="aCursorOffset">Start the position from the current cursor position to start deleting characters.</param>
967 /// <param name="aNumberOfChars">The number of characters to delete from the cursorOffset.</param>
968 /// <since_tizen> 5 </since_tizen>
969 public EventData(InputMethodContext.EventType aEventName, string aPredictiveString, int aCursorOffset, int aNumberOfChars) : this(Interop.InputMethodContext.NewInputMethodContextEventData((int)aEventName, aPredictiveString, aCursorOffset, aNumberOfChars), true)
971 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
974 internal EventData(IntPtr cPtr, bool cMemoryOwn)
976 swigCMemOwn = cMemoryOwn;
977 swigCPtr = new global::System.Runtime.InteropServices.HandleRef(this, cPtr);
981 /// The pre-edit or the commit string.
983 /// <since_tizen> 5 </since_tizen>
984 public string PredictiveString
988 Interop.InputMethodContext.EventDataPredictiveStringSet(swigCPtr, value);
989 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
993 string ret = Interop.InputMethodContext.EventDataPredictiveStringGet(swigCPtr);
994 if (NDalicPINVOKE.SWIGPendingException.Pending) throw new InvalidOperationException("FATAL: get Exception", NDalicPINVOKE.SWIGPendingException.Retrieve());
1000 /// The name of the event from the IMF.
1002 /// <since_tizen> 5 </since_tizen>
1003 public InputMethodContext.EventType EventName
1007 Interop.InputMethodContext.EventDataEventNameSet(swigCPtr, (int)value);
1008 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1012 InputMethodContext.EventType ret = (InputMethodContext.EventType)Interop.InputMethodContext.EventDataEventNameGet(swigCPtr);
1013 if (NDalicPINVOKE.SWIGPendingException.Pending) throw new InvalidOperationException("FATAL: get Exception", NDalicPINVOKE.SWIGPendingException.Retrieve());
1019 /// The start position from the current cursor position to start deleting characters.
1021 /// <since_tizen> 5 </since_tizen>
1022 public int CursorOffset
1026 Interop.InputMethodContext.EventDataCursorOffsetSet(swigCPtr, value);
1027 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1031 int ret = Interop.InputMethodContext.EventDataCursorOffsetGet(swigCPtr);
1032 if (NDalicPINVOKE.SWIGPendingException.Pending) throw new InvalidOperationException("FATAL: get Exception", NDalicPINVOKE.SWIGPendingException.Retrieve());
1038 /// The number of characters to delete from the cursorOffset.
1040 /// <since_tizen> 5 </since_tizen>
1041 public int NumberOfChars
1045 Interop.InputMethodContext.EventDataNumberOfCharsSet(swigCPtr, value);
1046 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1050 int ret = Interop.InputMethodContext.EventDataNumberOfCharsGet(swigCPtr);
1051 if (NDalicPINVOKE.SWIGPendingException.Pending) throw new InvalidOperationException("FATAL: get Exception", NDalicPINVOKE.SWIGPendingException.Retrieve());
1056 internal static global::System.Runtime.InteropServices.HandleRef getCPtr(EventData obj)
1058 return (obj == null) ? new global::System.Runtime.InteropServices.HandleRef(null, IntPtr.Zero) : obj.swigCPtr;
1061 internal static EventData GetEventDataFromPtr(IntPtr cPtr)
1063 EventData ret = new EventData(cPtr, false);
1064 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1069 /// You can override it to clean-up your own resources.
1071 /// <since_tizen> 5 </since_tizen>
1072 protected override void Dispose(DisposeTypes type)
1079 //Release your own unmanaged resources here.
1080 //You should not access any managed member here except static instance.
1081 //because the execution order of Finalizes is non-deterministic.
1083 if (swigCPtr.Handle != IntPtr.Zero)
1087 swigCMemOwn = false;
1088 Interop.InputMethodContext.DeleteInputMethodContextEventData(swigCPtr);
1090 swigCPtr = new global::System.Runtime.InteropServices.HandleRef(null, IntPtr.Zero);
1098 /// Data required by the IMF from the callback.
1100 /// <since_tizen> 5 </since_tizen>
1101 public class CallbackData : Disposable
1104 /// The state if it owns memory
1106 /// <since_tizen> 5 </since_tizen>
1107 //ToDo : raise ACR as [Obsolete("This has been deprecated in API9 and will be removed in API11. Please use SwigCMemOwn which is declared in parent class")]
1108 [System.Diagnostics.CodeAnalysis.SuppressMessage("Design", "CA1051:Do not declare visible instance fields", Justification = "<Pending>")]
1109 protected bool swigCMemOwn;
1110 private global::System.Runtime.InteropServices.HandleRef swigCPtr;
1113 /// The default constructor.
1115 /// <since_tizen> 5 </since_tizen>
1116 public CallbackData() : this(Interop.InputMethodContext.NewInputMethodContextCallbackData(), true)
1118 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1122 /// The constructor.
1124 /// <param name="aUpdate">True if the cursor position needs to be updated.</param>
1125 /// <param name="aCursorPosition">The new position of the cursor.</param>
1126 /// <param name="aCurrentText">The current text string.</param>
1127 /// <param name="aPreeditResetRequired">Flag if preedit reset is required.</param>
1128 /// <since_tizen> 5 </since_tizen>
1129 public CallbackData(bool aUpdate, int aCursorPosition, string aCurrentText, bool aPreeditResetRequired) : this(Interop.InputMethodContext.NewInputMethodContextCallbackData(aUpdate, aCursorPosition, aCurrentText, aPreeditResetRequired), true)
1131 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1135 /// The current text string.
1137 /// <since_tizen> 5 </since_tizen>
1138 public string CurrentText
1142 Interop.InputMethodContext.CallbackDataCurrentTextSet(swigCPtr, value);
1143 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1147 string ret = Interop.InputMethodContext.CallbackDataCurrentTextGet(swigCPtr);
1148 if (NDalicPINVOKE.SWIGPendingException.Pending) throw new InvalidOperationException("FATAL: get Exception", NDalicPINVOKE.SWIGPendingException.Retrieve());
1154 /// The current cursor position.
1156 /// <since_tizen> 5 </since_tizen>
1157 public int CursorPosition
1161 Interop.InputMethodContext.CallbackDataCursorPositionSet(swigCPtr, value);
1162 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1166 int ret = Interop.InputMethodContext.CallbackDataCursorPositionGet(swigCPtr);
1167 if (NDalicPINVOKE.SWIGPendingException.Pending) throw new InvalidOperationException("FATAL: get Exception", NDalicPINVOKE.SWIGPendingException.Retrieve());
1173 /// The state if the cursor position needs to be updated.
1175 /// <since_tizen> 5 </since_tizen>
1180 Interop.InputMethodContext.CallbackDataUpdateSet(swigCPtr, value);
1181 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1185 bool ret = Interop.InputMethodContext.CallbackDataUpdateGet(swigCPtr);
1186 if (NDalicPINVOKE.SWIGPendingException.Pending) throw new InvalidOperationException("FATAL: get Exception", NDalicPINVOKE.SWIGPendingException.Retrieve());
1192 /// Flags if the pre-edit reset is required.
1194 /// <since_tizen> 5 </since_tizen>
1195 public bool PreeditResetRequired
1199 Interop.InputMethodContext.CallbackDataPreeditResetRequiredSet(swigCPtr, value);
1200 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1204 bool ret = Interop.InputMethodContext.CallbackDataPreeditResetRequiredGet(swigCPtr);
1205 if (NDalicPINVOKE.SWIGPendingException.Pending) throw new InvalidOperationException("FATAL: get Exception", NDalicPINVOKE.SWIGPendingException.Retrieve());
1210 internal IntPtr GetCallbackDataPtr()
1212 return (IntPtr)swigCPtr;
1215 internal CallbackData(IntPtr cPtr, bool cMemoryOwn)
1217 swigCMemOwn = cMemoryOwn;
1218 swigCPtr = new global::System.Runtime.InteropServices.HandleRef(this, cPtr);
1221 internal static CallbackData GetCallbackDataFromPtr(IntPtr cPtr)
1223 CallbackData ret = new CallbackData(cPtr, false);
1224 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1229 /// You can override it to clean-up your own resources.
1231 /// <since_tizen> 5 </since_tizen>
1232 protected override void Dispose(DisposeTypes type)
1239 //Release your own unmanaged resources here.
1240 //You should not access any managed member here except static instance.
1241 //Because the execution order of Finalizes is non-deterministic.
1243 if (swigCPtr.Handle != IntPtr.Zero)
1247 swigCMemOwn = false;
1248 Interop.InputMethodContext.DeleteInputMethodContextCallbackData(swigCPtr);
1250 swigCPtr = new global::System.Runtime.InteropServices.HandleRef(null, IntPtr.Zero);
1258 /// InputMethodContext activated event arguments.
1260 /// <since_tizen> 5 </since_tizen>
1261 public class ActivatedEventArgs : EventArgs
1264 /// The instance of InputMethodContext
1266 /// <since_tizen> 5 </since_tizen>
1267 public InputMethodContext InputMethodContext
1275 /// InputMethodContext event receives event arguments.
1277 /// <since_tizen> 5 </since_tizen>
1278 public class EventReceivedEventArgs : EventArgs
1281 /// The instance of InputMethodContext
1283 /// <since_tizen> 5 </since_tizen>
1284 public InputMethodContext InputMethodContext
1291 /// The event data of IMF
1293 /// <since_tizen> 5 </since_tizen>
1294 public EventData EventData
1302 /// InputMethodContext status changed event arguments.
1304 /// <since_tizen> 5 </since_tizen>
1305 public class StatusChangedEventArgs : EventArgs
1308 /// InputMethodContext status.
1310 /// <since_tizen> 5 </since_tizen>
1311 public bool StatusChanged
1319 /// InputMethodContext resized event arguments.
1321 /// <since_tizen> 5 </since_tizen>
1322 public class ResizedEventArgs : EventArgs
1325 /// The state if the IMF resized.
1327 /// <since_tizen> 5 </since_tizen>
1336 /// InputMethodContext language changed event arguments.
1338 /// <since_tizen> 5 </since_tizen>
1339 public class LanguageChangedEventArgs : EventArgs
1342 /// Language changed.
1344 /// <since_tizen> 5 </since_tizen>
1345 public int LanguageChanged
1353 /// InputMethodContext keyboard type changed event arguments.
1355 /// <since_tizen> 5 </since_tizen>
1356 public class KeyboardTypeChangedEventArgs : EventArgs
1359 /// InputMethodContext keyboard type.
1361 /// <since_tizen> 5 </since_tizen>
1362 public KeyboardType KeyboardType
1370 /// InputMethodContext content received event arguments.
1372 /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
1373 [EditorBrowsable(EditorBrowsableState.Never)]
1374 public class ContentReceivedEventArgs : EventArgs
1377 /// The content, such as images, of input method
1379 /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
1380 [EditorBrowsable(EditorBrowsableState.Never)]
1381 public string Content
1387 /// The description of content
1389 /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
1390 [EditorBrowsable(EditorBrowsableState.Never)]
1391 public string Description
1397 /// The mime type of content, such as jpg, png, and so on
1399 /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
1400 [EditorBrowsable(EditorBrowsableState.Never)]
1401 public string MimeType