add Dialog.namespace() method, which returns the XML dialog's namespace
if the dialog is open and contains embedded <nasal>, or nil otherwise. This can be used to call dialog functions.
This commit is contained in:
parent
3079726bda
commit
ad8048627d
1 changed files with 9 additions and 3 deletions
|
@ -174,13 +174,19 @@ Dialog = {
|
|||
load : func {
|
||||
fgcommand("loadxml", props.Node.new({"filename": me.path,
|
||||
"targetnode": me.prop.getPath()}));
|
||||
var name = me.prop.getNode("name");
|
||||
if (name == nil) {
|
||||
var n = me.prop.getNode("name");
|
||||
if (n == nil) {
|
||||
die("Dialog class: XML dialog must have <name>");
|
||||
}
|
||||
me.prop.getNode("dialog-name", 1).setValue(name.getValue());
|
||||
me.name = n.getValue();
|
||||
me.prop.getNode("dialog-name", 1).setValue(me.name);
|
||||
fgcommand("dialog-new", me.prop);
|
||||
},
|
||||
# allows access to dialog-embedded Nasal variables/functions
|
||||
namespace : func {
|
||||
var ns = "__dlg:" ~ me.name;
|
||||
me.state and contains(globals, ns) ? globals[ns] : nil;
|
||||
},
|
||||
open : func {
|
||||
fgcommand("dialog-show", me.prop);
|
||||
me.state = 1;
|
||||
|
|
Loading…
Reference in a new issue