© 2009 OMTP Ltd. All rights reserved. OMTP and OMTP BONDI are registered trademarks of OMTP Ltd.
To allow widgets to access functions that integrate with the widget runtime user interface.
Menu
WidgetActivateCallback
WidgetDeactivateCallback
WidgetKeyPressCallback
WidgetOrientationChangeCallback
WidgetMenuSelectCallback
UIManager
MenuItem
| Interface | Method |
|---|---|
| WidgetActivateCallback | void onActivate() |
| WidgetDeactivateCallback | void onDeactivate() |
| WidgetKeyPressCallback | void onKeyPress(unsigned short keyCode) |
| WidgetOrientationChangeCallback | void onOrientationChange() |
| WidgetMenuSelectCallback | void onSelect() |
| UIManager | MenuItem getSoftKey(unsigned short id) void setOnActivate(WidgetActivateCallback handler) void setOnDeactivate(WidgetDeactivateCallback handler) void setOnKeyPress(WidgetKeyPressCallback handler) void beep(unsigned long duration, unsigned short frequency) void startVibrate(unsigned long duration, unsigned short intensity) void stopVibrate() void setOnOrientationChange(WidgetOrientationChangeCallback handler) void lightOn(unsigned long duration, unsigned short intensity, boolean fadeIn) void lightOff(boolean fadeOut) |
| MenuItem | void setOnSelect(WidgetMenuSelectCallback handler) MenuItem getMenuItemById(unsigned long id) MenuItem appendMenuItem(unsigned long id, DOMString text, WidgetMenuSelectCallback onSelect) void removeMenuItem(unsigned long id) void removeAllMenuItems() |
This module provides a mechanism to interact with the end-user or configure the way in which the user visualizes or navigates Web applications. This includes features such as:
- navigation mechanisms
- soft-key and menu configuration
- effectors, vibration, sounds, screen brightness
- configuration of general appearance, e.g. portrait/landscape, full-screen
- behaviour configuration when moving from foreground to background.
Some ui operations are not supported outside of the widget runtime context. Examples are modifying the device soft key menus, and de-activating a widget. A DeviceAPIError exception is thrown with code NOT_SUPPORTED_ERROR when script attempts to perform an operation that is not supported.
No permissions are required for this package.
function errorCB(err) {
alert("BONDI ui API couldn't be requested: " + err.message);
}
function successCB() {
// Create a single menu on the left soft key to close the widget.
var leftMenu = bondi.ui.getSoftKey(bondi.ui.LEFT_SOFT_KEY);
var d = leftMenu.removeAllMenuItems();
leftMenu.text = "Close";
// When the menu is selected, de-activate the widget.
leftMenu.setOnSelect(function() { bondi.ui.isActive = false; });
}
bondi.requestFeature(successCB, errorCB, "ui");
Menu
Array of MenuItems.
typedef sequence<MenuItem> Menu;
WidgetActivateCallback
Callback interface to handle widget activation notifications.
[Callback=FunctionOnly, NoInterfaceObject] interface WidgetActivateCallback {
void onActivate();
};
onActivate
Method invoked when the widget is activated
void onActivate();
WidgetDeactivateCallback
Callback interface to handle widget deactivation notifications.
[Callback=FunctionOnly, NoInterfaceObject] interface WidgetDeactivateCallback {
void onDeactivate();
};
onDeactivate
Method invoked when the widget is deactivated
void onDeactivate();
WidgetKeyPressCallback
Callback interface to handle keypress notifications.
[Callback=FunctionOnly, NoInterfaceObject] interface WidgetKeyPressCallback {
void onKeyPress(in unsigned short keyCode);
};
onKeyPress
Method invoked when a key is pressed
void onKeyPress(unsigned short keyCode);
WidgetOrientationChangeCallback
Callback interface to handle display orientation change notifications.
[Callback=FunctionOnly, NoInterfaceObject] interface WidgetOrientationChangeCallback {
void onOrientationChange();
};
onOrientationChange
Method invoked when the display orientation is changed
void onOrientationChange();
WidgetMenuSelectCallback
Callback interface to handle menu selection notifications.
[Callback=FunctionOnly, NoInterfaceObject] interface WidgetMenuSelectCallback {
void onSelect();
};
onSelect
Method invoked when a menu option has been selected
void onSelect();
UIManager
UIManager interface.
interface UIManager {
const unsigned short LEFT_SOFT_KEY = 0;
const unsigned short RIGHT_SOFT_KEY = 1;
MenuItem getSoftKey(in unsigned short id)
raises(DeviceAPIError);
void setOnActivate(in WidgetActivateCallback handler)
raises(DeviceAPIError);
void setOnDeactivate(in WidgetDeactivateCallback handler)
raises(DeviceAPIError);
attribute boolean isActive
setraises(DeviceAPIError);
const unsigned short NAVIGATION_CURSOR = 0;
const unsigned short NAVIGATION_TABBED = 1;
attribute unsigned short navigationMode
setraises(DeviceAPIError);
void setOnKeyPress(in WidgetKeyPressCallback handler)
raises(DeviceAPIError);
void beep(in unsigned long duration,in unsigned short frequency);
const unsigned short INFINITE_DURATION = 0;
void startVibrate(in unsigned long duration, in unsigned short intensity);
void stopVibrate();
readonly attribute boolean isRotationSupported;
const unsigned short ORIENTATION_0 = 0;
const unsigned short ORIENTATION_90 = 90;
const unsigned short ORIENTATION_180 = 180;
const unsigned short ORIENTATION_270 = 270;
attribute unsigned short displayOrientation;
void setOnOrientationChange(in WidgetOrientationChangeCallback handler)
raises(DeviceAPIError);
attribute boolean softKeysVisible
setraises(DeviceAPIError);
attribute boolean statusBarVisible
setraises(DeviceAPIError);
void lightOn(in unsigned long duration, in unsigned short intensity, in boolean fadeIn);
void lightOff(in boolean fadeOut);
};
This is the top-level interface for the org.omtp.bondi.ui module. It allows widgets to access functions that integrate with the WRT user interface
function errorCB(err) {
alert("BONDI ui API couldn't be requested: " + err.message);
}
function successCB() {
// Create a single menu on the left soft key to close the widget.
var leftMenu = bondi.ui.getSoftKey(bondi.ui.LEFT_SOFT_KEY);
var d = leftMenu.removeAllMenuItems();
leftMenu.text = "Close";
// When the menu is selected, de-activate the widget.
d = leftMenu.setOnSelect(function() { bondi.ui.isActive = false; });
}
bondi.requestFeature(successCB, errorCB, "ui");
unsigned
short
LEFT_SOFT_KEY
Constant for getSoftKey method.
This constant is used in conjunction with getSoftKey to specify which soft key to retrieve.
// Get the left soft key menu item and set the text.
var leftMenu = bondi.ui.getSoftKey(bondi.ui.LEFT_SOFT_KEY);
leftMenu.text = "Close";
unsigned
short
RIGHT_SOFT_KEY
Constant for getSoftKey method.
This constant is used in conjunction with getSoftKey to specify which soft key to retrieve.
// Get the right soft key menu item and set the text.
var rightMenu = bondi.ui.getSoftKey(bondi.ui.RIGHT_SOFT_KEY);
rightMenu.text = "Options";
unsigned
short
NAVIGATION_CURSOR
Constant for navigationMode property.
Indicates that the widget will use a pointer type mode of navigation.
unsigned
short
NAVIGATION_TABBED
Constant for navigationMode property.
Indicates that the widget wants to receive keyboard navigation.
unsigned
short
INFINITE_DURATION
Vibration constants.
unsigned
short
ORIENTATION_0
Constant for displayOrientation property.
unsigned
short
ORIENTATION_90
Constant for displayOrientation property.
unsigned
short
ORIENTATION_180
Constant for displayOrientation property.
unsigned
short
ORIENTATION_270
Constant for displayOrientation property.
boolean
isActive
Property for access to the foreground status of the widget.
This property can be used to query the foreground status of the widget as well as to send the widget to the background or bring it to the foreground.
// Send widget to background.
bondi.ui.isActive = false;
Property for access to the navigation mode.
// Set the navigation mode.
bondi.ui.navigationMode = bondi.ui.NAVIGATION_TABBED;
[readonly]
boolean
isRotationSupported
Determines if the device supports changes in display orientation.
This property is read-only.
unsigned
short
displayOrientation
Display orientation property.
This method can be used to query the current display orientation, as well as to set a new display orientation.
// Set the display orientation to 90 degrees.
bondi.ui.displayOrientation = bondi.ui.ORIENTATION_90;
boolean
softKeysVisible
Property to set the soft key visibility.
This property can be used to query as well as set the visibility of the device softkey menu bar.
Note: if you hide the softKeys remember to add a means to close/deactivate your widget to the user interface.
// Hide the softkeys.
bondi.ui.softKeysVisible = false;
boolean
statusBarVisible
Property to set the status bar visibility.
This property can be used to query as well as set the visibility of the device status bar.
// Go fullscreen.
bondi.ui.softKeysVisible = false;
bondi.ui.statusBarVisible = false;
getSoftKey
Access the top-level menuitem object.
MenuItem getSoftKey(unsigned short id);
Used to access the top-level menuitem object of the device soft-key for the specified side.
// Get the left soft-key.
var leftMenu = bondi.ui.getSoftKey(bondi.ui.LEFT_SOFT_KEY);
// Set the soft-key text.
leftMenu.text = 'Close';
// Set a handler so that when the soft-key is pressed the widget is sent to the background.
leftMenu.setOnSelect(function() { bondi.ui.isActive = false; });
setOnActivate
Set handler for widget activation notification.
void setOnActivate(WidgetActivateCallback handler);
Notifies when the widget is activated and brought to the foreground.
// Request to be notified when the widget is activated.
function goToForeground()
{
// Widget is now in the foreground.
// Start processor intensive routine...
}
bondi.ui.setOnActivate(goToForeground);
setOnDeactivate
Set handler for widget de-activation notification.
void setOnDeactivate(WidgetDeactivateCallback handler);
Notifies when the widget is de-activated and sent to the background.
// Request to be notified when the widget is de-activated.
function goToBackground()
{
// Widget is now in the background.
// kill processor intensive routine...
}
bondi.ui.setOnDeactivate(goToBackground);
setOnKeyPress
Sets the handler to receive key input.
void setOnKeyPress(WidgetKeyPressCallback handler);
This handler is called if the navigation mode is set to NAVIGATION_TABBED.
beep
Produce a beep from the device.
void beep(unsigned long duration, unsigned short frequency);
Note: duration and frequency parameters are ignored in this implementation.
startVibrate
Switch on the device vibration for the specified period and intensity.
void startVibrate(unsigned long duration, unsigned short intensity);
Note: intensity parameter is ignored in this implementation.
stopVibrate
Switches off the device vibration.
void stopVibrate();
setOnOrientationChange
Sets a handler to receive notification when screen orientation changes.
void setOnOrientationChange(WidgetOrientationChangeCallback handler);
Note: not implemented in v1.0.
lightOn
Switches the backlight on for the given duration.
void lightOn(unsigned long duration, unsigned short intensity, boolean fadeIn);
Note: intensity and fadeIn parameters are ignored in this implementation.
lightOff
Switches the backlight off.
void lightOff(boolean fadeOut);
Note: fadeOut parameter ignored in this implementation.
MenuItem
MenuItem interface.
interface MenuItem {
readonly attribute unsigned long id;
attribute DOMString text;
void setOnSelect(in WidgetMenuSelectCallback handler)
raises(DeviceAPIError);
readonly attribute Menu menuItems;
MenuItem getMenuItemById(in unsigned long id);
MenuItem appendMenuItem(in unsigned long id, in DOMString text, in WidgetMenuSelectCallback onSelect)
raises(DeviceAPIError);
void removeMenuItem(in unsigned long id)
raises(DeviceAPIError);
void removeAllMenuItems();
};
This interface provides the ability to interact with and modify the widget runtime soft-key menus. MenuItem has access to the collection of child menu items via menuItems array.
var leftMenu = bondi.ui.getSoftKey(bondi.ui.LEFT_SOFT_KEY);
leftMenu.text = "refresh";
[readonly]
unsigned
long
id
Get the id of this menu item.
This property is read-only.
var id = menuItem.id;
DOMString
text
Gets/Sets the text of the menu item.
var menuItem = bondi.ui.getSoftKey(bondi.ui.RIGHT_SOFT_KEY);
var menuItem.text = "Options";
Gets the child items of this menu item.
var menuItem = bondi.ui.getSoftKey(bondi.ui.RIGHT_SOFT_KEY);
var subMenu = menuItem.menuItems;
setOnSelect
Sets the handler to be called when the menu item is selected.
void setOnSelect(WidgetMenuSelectCallback handler);
var menuItem = bondi.ui.getSoftKey(bondi.ui.RIGHT_SOFT_KEY);
var menuItem.text = "Say hello";
menuItem.setOnSelect(function() { alert("hello!"); });
getMenuItemById
Retrieves a menu item from the child nodes (menuItems) using the id.
MenuItem getMenuItemById(unsigned long id);
appendMenuItem
Adds a child menu item to this menu item.
MenuItem appendMenuItem(unsigned long id, DOMString text, WidgetMenuSelectCallback onSelect);
var menuItem = bondi.ui.getSoftKey(bondi.ui.RIGHT_SOFT_KEY);
var menuItem.text = "Options";
var colourMenu = menuItem.appendMenuItem(0,"Change colour",onColourChange);
removeMenuItem
Removes the menu item with the given id from the child nodes (menuItems).
void removeMenuItem(unsigned long id);
removeAllMenuItems
Removes all child menu items from this menu item.
void removeAllMenuItems();