1
0
Fork 0

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:
mfranz 2007-02-26 11:00:04 +00:00
parent 3079726bda
commit ad8048627d

View file

@ -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;