Input Method
The IME (Input Method Editor) is an input panel (keyboard) that lets the user input text and the platform receive the entered data. The user can select an IME as their default keyboard in the device Settings application.
You can create an application that provides a new IME. You can start the IME application life-cycle, interact with the current IME UI state, and retrieve attributes and events.
The main features of the Tizen.Uix.InputMethod namespace include the following:
-
Managing the IME life-cycle
The system can have multiple keyboards, and the user can choose which one to use as the default keyboard. The IME application starts its life-cycle when it is selected as the default keyboard. The following figure shows the IME application life-cycle.
Figure: IME application life-cycle
The IME application runs in the following way:
-
Once the IME application is started, the
Create()
event handler is called. -
When a text input UI control receives focus, the
Show()
event handler is called.The IME application can call
Tizen.Uix.InputMethod
methods to interact with the UI control. The event handlers are called when the UI control state changes. When the text input UI control loses focus, theHide()
event handler is called. -
When the IME application is finished, the
Terminate()
event handler is called.
-
-
Managing the main loop and event handlers
The IME application must implement the
Main()
method. It is the main entry point, in which you can register event handlers and call theRun()
method of the Tizen.Uix.InputMethod.InputMethodEditor class to start the main loop.During its life-cycle, the IME application can receive a number of events from the Tizen input service framework through the event handlers. You must register the mandatory
Create()
,Terminate()
,Show()
, andHide()
event handlers. Other event handlers can be registered as required by the specific IME application. -
Showing and hiding the keyboard
When an associated text input UI control has focus, the active keyboard is shown. When the text input UI control loses focus, the keyboard is hidden.
The
Show()
andHide()
event handlers are used to manage the keyboard visibility, and the IME application must register both of them when starting the IME main loop.The client application can set various configurations for each text input UI control, such as the cursor position, key layout type, return key type, and flags for predictive text. The configurations are delivered to the IME application through the
Show()
event handler, to allow the keyboard to show the correct appearance to the user.
Prerequisites
To enable your application to use the input method functionality follow these steps:
-
To use the Tizen.Uix.InputMethod namespace, the application has to request permission by adding the following privilege to the
tizen-manifest.xml
file:XMLCopy<privileges> <privilege>http://tizen.org/privilege/ime</privilege> </privileges>
-
To use the methods and properties of the Tizen.Uix.InputMethod namespace, include it in your application:
C#Copyusing Tizen.Uix.InputMethod;
Start the IME life-cycle
To start the IME application life-cycle, follow these steps:
-
Register the mandatory
Create()
,Terminate()
,Show()
, andHide()
event handlers:C#Copyinternal static void Create() {} internal static void Terminate() {} internal static void Show(InputMethodEditor.ContextId id, InputMethodContext ctx) {} internal static void Hide(InputMethodEditor.ContextId id) {}
-
Implement the
Main()
method as the main entry point of the IME application:C#Copystatic void Main(string[] args) {
The method is called when the user selects the IME as default from the IME selector menu.
-
Inside the
Main()
method, add the required event handlers and call theRun()
method to start the application:C#CopyInputMethodEditor.Run(Create, Terminate, Show, Hide); }
Use floating keyboard
To allow the user to move the floating keyboard, follow these steps:
-
Call the
SetFloatingMode()
method:C#Copypublic static void SetFloatingMode() { InputMethodEditor.SetFloatingMode(true);
-
Create a container of PanGestureRecognizer to detect a dragging event:
C#Copyvar panGesture = new PanGestureRecognizer (); panGesture.PanUpdated += OnPanUpdated; GestureRecognizers.Add (panGesture);
-
Call the
SetFloatingDragStart()
andSetFloatingDragEnd()
methods when a drag event is received:C#Copyvoid OnPanUpdated (object sender, PanUpdatedEventArgs e) { switch (e.StatusType) { case GestureStatus.Running: InputMethodEditor.SetFloatingDragStart(); break; case GestureStatus.Completed: InputMethodEditor.SetFloatingDragEnd(); break; } }
Related information
- Dependencies
- Tizen 4.0 and Higher