Displaying Messages to Your Users
The minimessage library
enables the developer to display a message window to a user.
This is a valuable feature when you’re trying to obtain user input or
display status messages to a user that autodismiss after a short
interval.
To integrate this feature, take the following steps:
Within the
ModulePrefsnode of the gadget spec file, add aRequireelement to enable theminimessageJavaScript library.Include:
<Require feature="minimessage"/>
Within the gadget JavaScript layer, insert an initialization function for the mini-message features.
Method call:
var message = new gadgets.MiniMessage(__MODULE_ID__);
When you wish to create a new message window, call one of three message window request methods.
Dismissible message:
message.createDismissibleMessage("My Message", callback);Static message:
message.createStaticMessage("My Message");Timer message:
message.createTimerMessage("My Message", 3, callback);
As noted in step 3, there are three different message types that a gadget implementer may specify:
- Dismissible message
Remains visible until the user manually closes the window.
- Static message
Remains visible until the code-specified event occurs. This message may be dismissed only via the gadget code.
- Timer message
Remains visible until a predefined timeout occurs. These messages will autoclose when the allotted time expires.
Moving from basic concepts into functional examples, next we’ll explore how to build and customize message windows using the available JavaScript ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access