You can get the framework to display a completely custom dialog consisting of your own HTML. This mechanism is very flexible, because you can do bi-directional communication between your widget/script and the dialog while it is open, but it is complicated. It involves you having to assemble a string containing HTML and Javascript inside your code (unless you use a web page hosted externally). In a widget, but not a script or UDIX, it may be simpler to have the widget act as its own dialog.
You create an HTML dialog using
You can send messages from your widget/script/UDIX to the dialog.
The dialog can send messages to your widget/script/UDIX.
The dialog has no access to the framework. You can send messages to the dialog containing framework data, and the dialog can send you messages asking your widget/script/UDIX to carry out framework actions. But the dialog itself cannot access the framework.
The dialog cannot close itself. It needs to send a message to your widget/script/UDIX, and your widget/script/UDIX then uses
As an example, take the following widget/script/UDIX code which builds a string containing an HTML document, including a
var html = "<html><head>";
html += "<script>";
html += "function SendUpdateToParent(txt) {window.parent.postMessage(txt, '*');};"
html += "window.addEventListener('message', function(event) {";
html += "document.getElementById('lblEquity').innerText = event.data;";
html += "});"
html += "</script>";
html += "</head><body>";
html += "<p>Equity: <span id='lblEquity'>...</span></p>"
html += "<p><button onclick='SendUpdateToParent(\"close-me\");'>Close</button></p>";
html += "</body></html>";
Various things are happening here:
The
There is a button in the page which uses
The Javascript in the HTML sets up a listener on
You can then create such a dialog as follows:
Framework.CreateHtmlDialog({
title: "My dialog",
html: html
}, function(Msg) {
if (Msg.result) {
// Dialog has been closed/cancelled. Remove the timer which we set up earlier.
clearInterval(Framework.$myTimer);
} else if (Msg.update) {
// Some kind of message from the dialog, via window.parent.postMessage()
if (Msg.update == "close-me") {
// Dialog is asking to be closed
Framework.DestroyDialog(Msg.widgetId);
} else {
// Some other message
}
} else {
// If not a result and not an update, then this is the initial message
// giving us the dialog's ID (in Msg.widgetId).
// As a simple example, we will send the dialog the current account equity
// once per second.
setInterval(function() {
Framework.$myTimer = Framework.SendHtmlDialogUpdate(Msg.widgetId, Framework.Account.equity);
}, 1000);
}
});
Again, a number of things are happening in this widget/script/UDIX code:
The asynchronous callback handler from
If the
If the
If the
All this is obviously not a very realistic example in itself. But exactly the same principles used here can be extended to create very feature-rich dialogs, all ultimately based on the same message-exchange demonstrated above.
Finally, in addition to the
| Property | Description |
| url | If you supply a |
| noTitle | If |
| noStandardCss | By default the framework will insert its own CSS into your HTML (not applicable if you use a |
| buttons | You can optionally give the dialog standard buttons, in a footer, in exactly the same way as for dialogs such as Ask(). These buttons will close your dialog in the usual way, sending back a |