This section only applies to widgets. It does not apply to scripts or UDIXes because they have no web page.
A widget can display itself as a dialog. This can be simpler than using CreateHtmlDialog(). For example, your widget can have HTML as follows:
<html>
<head>…</head>
<body>
<div id="NormalContent">
<!-- Normal widget content -->
</div>
<div id="DialogContent">
<!-- Different content when displayed as a dialog -->
</div>
</body>
</html>
On start-up, typically in
Framework.OnLoad = function() {
// Check the mode. See below…
if (Framework.privateSettings.asDialog) {
// Dialog mode
// Hide the normal content and show the dialog content
document.getElementById("NormalContent").style.display = "none";
document.getElementById("DialogContent").style.display = "block";
// Do initialisation for dialog mode
} else {
// Normal mode
// Show the normal content and hide the dialog content
document.getElementById("NormalContent").style.display = "block";
document.getElementById("DialogContent").style.display = "none";
// Do normal initialisation
}
};
From normal mode, you display the widget as its own dialog using
Framework.CreateDialog({
// Use own type as the type for the dialog
type: Framework.type,
// Pass settings to the dialog. These are received as Framework.privateSettings
// The asDialog flag signals to the widget's own code that it is in dialog mode
// rather than normal mode, as illustrated above. The settings:{} block can
// contain any further data which you want to pass into the dialog
settings: {
asDialog: true
}
}, function (Msg) {
// Asynchronously receives a result, plus any updates, from the dialog
// (Behaves just like the built-in dialogs described in the sections above)
});
In other words, the main widget passes settings to the dialog containing
The dialog can send a result back to the main widget using
// Create FXB.Result object
var result = new FXB.Result(0); // Can be initialised with 0 (okay) or any error code
// Add in any proprietary data to the FXB.Result. For example:
result.myData = {
someKey: someValue
};
// Send the result back to the creator. This closes the dialog.
Framework.SendDialogResult(result);
The dialog can cancel itself, rather than sending a result, using
The dialog can also send interim updates back to the creator, using
The main widget receives information from or about the dialog in its asynchronous callback function for
Framework.CreateDialog({ … }, function (Msg) {
if (Msg.result) {
// If Msg has a .result, then the dialog has now closed (or been dismissed)
} else if (Msg.update) {
// If Msg has an .update, then the dialog is using SendDialogUpdate()
} else {
// If neither .result nor .update, then it's the initial message about creation
}
});
(It's also possible for the main widget and the instance acting as a dialog to exchange other messages, as well as using the standard