|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
Object | +--widget
The widget object
The widget objects contains properties and method which can be used to manipulate the currently running widget. The object is only available to documents which are packaged as widgets, i.e. which are loaded using a config.xml file. It is available in the global scope.
widget.setPreferenceForKey('gautamc', 'username');
Roughly, the widget object supplies functions and properties for the following features:
The following properties and methods were introduced in Opera 9.5. They are not available in 9.2x and below.
All other properties and methods have been available since 9.2x.
Field Summary | |
String |
identifier
The unique identifier of this widget. |
Function |
onHide
Function to call when the widget is hidden. |
Function |
onShow
Function to call when the widget is shown after being hidden. |
String |
originURL
The URL this widget was downloaded from. |
String |
widgetMode
The current display of this widget. |
Constructor Summary | |
widget()
This class does not have a public constructor. |
Method Summary | |
void
|
getAttention()
Get the user's attention. |
void
|
hide()
Hide the widget. |
void
|
openURL( <String> url )
Open a URL in the web browser. |
String
|
preferenceForKey(<String> key)
Get a preference from the widget preference store. |
void
|
setPreferenceForKey( <String> value, <String> key )
Save a widget preference. |
void
|
show()
Show the previously hidden widget. |
void
|
showNotification( <String> message, <Function> callback )
Show a notification to the user. |
Field Detail |
String identifier
Function onHide
Function onShow
String originURL
String widgetMode
widgetmodechange
event will be fired on the widget object if the mode changes.
Constructor Detail |
widget()
Method Detail |
void getAttention()
void hide()
Calling this method will hide the widget from view. It will not appear as a window or in the task bar, but will continue to run in the background. If the widget is already hidden, calling this method will do nothing.
When the widget is hidden, the widget.onHide function is called.
void openURL( <String> url )
url
- The URL to open
String preferenceForKey(<String> key)
key
- The preference to get from the preference store
void setPreferenceForKey( <String> value, <String> key )
This method will store the given value in the widget in the widget preference store for the given key. The preference store is unique to this widget and any values stored in it are persisted if the widget is reloaded or closed and started again. If a value for the given key already exists, it is silently overwritten.
Storing an empty string for the given key will create an entry for the given key with an empty string as its value.
Calling this method with null
as the value will unset any value previously set.>
Note that the order of the arguments. This and the name of the method is this way to promote compatibility with Dashboard widgets.
value
- The value of the preference
key
- The string to save the preference under.
void show()
Calling this method will bring the widget out of hiding, reopening the window and showing it in the task bar for the desktop browser. An example is opening the widget when interesting data or requests were received, by calling widget.show() in the callback to widget.showNotification(). If the widget is already visible, calling this method will do nothing.
When the widget is shown, the widget.onShow function is called.
void showNotification( <String> message, <Function> callback )
Calling this method will show a notification with the given message to the user in some way. This will vary with device. On desktop, a popup similar to messages about new mails.
If the user accepts the notification, for example by clicking on it, the given callback is called. If the user ignores the notification, the callback is never called.
This feature can be used to bring a widget out of hiding when something significant occurs, for example that new weather data has been received.
message
- Message to display.
callback
- Callback to call when the notification is acted on.
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |