top

Widget Object

Published 2014-10-28 | (Compatible with SDK 2.5,3.5,4.5,5.0,5.1 and 2011,2012,2013,2014 models)

Provides functions needed for running an application efficiently.

Contents

Widget object has functions needed for running an application efficiently, such as a method that notifies the Application Manager of the starting of an application, a method that registers and frees up keys the users want to use, and so on.

Widget  
Library path $MANAGER_WIDGET/Common/API/Widget.js
Syntax new Common.API.Widget()
Methods

sendReadyEvent()

sendExitEvent()

sendReturnEvent()

blockNavigation()

putInnerHTML()

Parameter None
Return Value Widget object
Remarks Since Samsung Smart TV version 2.265
Example
var widgetAPI = new Common.API.Widget();
    widgetAPI.sendReadyEvent();
Members None

Methods

sendReadyEvent

The sendReadyEvent() method notifies the Application Manager that the application is ready to be displayed. This event is passed to the display and the application is run on the screen.

Syntax sendReadyEvent()
Parameter None
Return Value None
Enumeration None
Remarks Since Samsung Smart TV version 2.265
Example
var widgetAPI = new Common.API.Widget();
    widgetAPI.sendReadyEvent();

sendExitEvent

The sendExitEvent() method brings about the same effect as pressing the Exit key. Stops the application and returns to the TV screen.

Syntax sendExitEvent()
Parameter None
Return Value None
Enumeration None
Remarks Since Samsung Smart TV version 2.265
Example
var widgetAPI = new Common.API.Widget();
    widgetAPI.sendExitEvent();

sendReturnEvent

The sendReturnEvent() method brings about the same effect as pressing the Return key. Finishes the application and takes you to the Application Manager.

Syntax sendReturnEvent()
Parameter None
Return Value None
Enumeration None
Remarks Since Samsung Smart TV version 2.265
Example
var widgetAPI = new Common.API.Widget();
    widgetAPI.sendReturnEvent();

blockNavigation

The blockNavigation() method ensures that key event cannot be forced to return.

Syntax blockNavigation(keyEvent)
Parameter keyEvent: Key event
Return Value None
Enumeration None
Remarks

The KEY_RETURN and KEY_EXIT events forcibly close the operating application. The function prevents forced closure and keep being executing.

Since Samsung Smart TV version 2.265

Example
function keyDown() {
    switch(event.keyCode) {
        case this.tvKey.KEY_LEFT:
            // Do something
            break;
        case this.tvKey.KEY_RIGHT:
            // Do something
            break;
        case this.tvKey.KEY_RETURN:
            widgetAPI.blockNavigation(event);
            // Not terminated
            break;
        case this.tvKey.KEY_EXIT:
            // Terminated by force
            break;
        default:
            break;
    }
}

putInnerHTML

The putInnerHTML() method fixes memory issues.

Syntax putInnerHTML(div, contents)
Parameter

div: Div Element to use innerHTML

contents: Things to insert in innerHTML

Return Value None
Enumeration None
Remarks

Required to use this method because the repetitive use of innerHTML can cause memory issues.

Since Samsung Smart TV version 2.265

Example
var widgetAPI = new Common.API.Widget();
var divElement = document.getElementById("divID");
var contents = "Text to change";
    widgetAPI.putInnerHTML(divElement, contents);