The Samsung SmartTV IME Module for Application Development
The IME module is the most common way to get user input in a SmartTV application. The IME module is matched to an <input> element ID, and requires some exception handling. The Samsun Developers’ Forum (SDF) provides many member functions and properties to help in using the IME, which can be used to implement advanced functions such as login and keyword searches in a SmartTV application.
A SmartTV application often includes a search or login feature to meet its service purpose. The Samsung SmartTV provides the IME module to collect user data input. The IME can be accessed by using a remote controller, through a virtual keyboard, as shown here.
The first step in using an IME is adding an <input> element on the HTML page.
The preceding <input> element displays the user IME input, while also helping in creating an IME object and handling the focus. Make sure to assign a maxlength value to avoid user confusion and IME system errors resulting from endless typing. The maxlength property can have a maximum value of 256 characters.
In addition to the <input> element, the Common Module API needs to be loaded since it includes the IME module. This allows the IME to be called.
The declared Common Module API can be used to receive an IME instance to create an IME object. An <input> element’s ID must be immediately entered into the newly created object’s inputboxID member variable.
Assuming a correct inputboxID value is entered, the IME module will be called when the input box is selected. Once the IME module is called, it will take care of the user remote control input process on its own.
onKeyPressFunc( ) callback function
The onKeyPressFunc() is vital for using the IME module.
The onKeyPressFunc() is very important because it defines how the application reacts when IME user input is complete. This function can modify the input data and allocate it to necessary UI components.
The onKeyPressFunc() always runs when the IME module exits, which is caused by pressing the remote control exit or return key, or by selecting OK or the return key on the virtual keyboard.
The following custom function calls the IME module with its internally defined onKeyPressFunc().
IME member functions
The following member functions are also frequently used while using the IME module.
The Samsung Developers’ Forum (SDF) guides use the onClose function to manually close any open IME module.
12 keys and QWERTY keyboards
The 12 Keys keyboard is similar to the 9 numeric keys on a SmartTV remote controller. Only the input element can be focused in this IME type, which will display a bound value or generate an even value whenever one of the 12 keys is pressed. The lower-left “-” key will switch the keyboard type.
The QWERTY keyboard is similar to a regular computer keyboard. All the virtual keyboard buttons, in addition to the input box, can receive the focus. Use the four directional keys to move the focus to a desired button and press to enter a character.
The 12 Keys and QWERTY keyboards have almost the same programming methods, except some minor differences. The IME module can control both of the keyboards, which can be tested by the Emulator. The last-used keyboard by the user will become the default keyboard in the next IME input. The two keyboards can be switched during an input, with a remote controller.