Hi fellow wiki editors!

To help newly registered users get more familiar with the wiki (and maybe older users too) there is now a {{Welcome to the wiki}} template. Have a look at it and feel free to add it to new users discussion pages (and perhaps your own).

I have tried to keep the template short, but meaningful. /Johan G

Difference between revisions of "Howto:Hooking into the GUI"

From FlightGear wiki
Jump to: navigation, search
m (pm2wiki)
Line 17: Line 17:
 
var myDialog = {};
 
var myDialog = {};
  
myDialog[name] = gui.Widget.new();
+
myDialog = gui.Widget.new();
myDialog[name].set("name", name);
+
myDialog.set("name", name);
myDialog[name].set("layout", "vbox");
+
myDialog.set("layout", "vbox");
  
  
var graph = myDialog[name].addChild("graph");
+
var image = myDialog.addChild("image");
graph.set("name", "foo");
+
image.set("name", "someImage");
  
 
+
var cancel = myDialog.addChild("button");
var code = "io.load_nasal(getprop('sim/fg-root') ~ '/Nasal/foo.bar');";
+
graph.addChild("nasal").set("load", code);
+
 
+
var cancel = myDialog[name].addChild("button");
+
 
cancel.set("key", "Esc");
 
cancel.set("key", "Esc");
 
cancel.set("legend", "Cancel");
 
cancel.set("legend", "Cancel");
 
cancel.setBinding("dialog-close");
 
cancel.setBinding("dialog-close");
  
#props.dump( myDialog[name].prop() );
+
fgcommand("dialog-new", myDialog.prop() );
fgcommand("dialog-new", myDialog[name].prop() );
+
 
gui.showDialog(name);
 
gui.showDialog(name);
  

Revision as of 17:13, 11 March 2018

This article is a stub. You can help the wiki by expanding it.
fgcommand("register-widget", props.Node.new({
 "module": "ui",
 "name": "image",
 "script": "props.dump( cmdarg() );"
}));


var name = "test";
var myDialog = {};

myDialog = gui.Widget.new();
myDialog.set("name", name);
myDialog.set("layout", "vbox");


var image = myDialog.addChild("image");
image.set("name", "someImage");

var cancel = myDialog.addChild("button");
cancel.set("key", "Esc");
cancel.set("legend", "Cancel");
cancel.setBinding("dialog-close");

fgcommand("dialog-new", myDialog.prop() );
gui.showDialog(name);



Related

References