10

IME

Using IME

IME Member Functions

12 Keys and QWERTY Keyboards

Summary

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 below.

images

Figure 10-1. Text Input Using the IME

Using IME

Initialization

The first step in using an IME is adding an <input> element on the HTML page.

<input id=“ime_test” type=“text” size=“10” maxlength=“256” height=“30” />

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.

<!-- IME module -->
    <script type=“text/javascript” language=“javascript” src=“$MANAGER_WIDGET/
Common/IME_XT9/ime.js”></script>
    <script type=“text/javascript” language=“javascript” src=“$MANAGER_WIDGET/
Common/IME_XT9/inputCommon/ime_input.js”></script>

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.

// create an IME object
// set InputBox ID in the IME object
oIME = new IMEShell_Common();
oIME.inputboxID = “ime_test”;

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.

// this callback function handles key press events
// that cause the IME module to exit.
oIME.onKeyPressFunc = function(keyCode) {
    switch(keyCode)
    {
        case tvKey.KEY_RETURN:
            break;
        case tvKey.KEY_EXIT:
            break;
        case tvKey.KEY_ENTER:
            break;
    }
};

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().

var focusIME = function() {
    oIME = new IMEShell_Common();
    oIME.inputboxID = “ime_test”;
    oIME.onKeyPressFunc = function(keyCode) {
        switch(keyCode)
        {
            case tvKey.KEY_RETURN:
                break;
            case tvKey.KEY_EXIT:
                break;
            case tvKey.KEY_ENTER:
                break;
        }
    };

    jQuery(‘#ime_test’).focus();
    oIME.onShow();
};

IME Member Functions

The following member functions are also frequently used while using the IME module.

images

Table 10-1. IME.onClose ()

images

Table 10-2. IME.inputTitle ()

images

Table 10-3. IME.onCompleteFunc

images

Table 10-4. IME.showAutoCompletePopup()

The SDF guides use the onClose function to manually close any open IME module.

12 Keys and QWERTY Keyboards

12 Keys Type

images

Figure 10-2. 12 Keys Type

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.

QWERTY Type

images

Figure 10-3. QWERTY Type

images

Figure 10-4. QWERTY Type (2013)

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.

Summary

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 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.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset