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
(Registering the pre-processor)
(Testing the new tag/widget)
Line 16: Line 16:
  
 
==  Testing the new tag/widget ==
 
==  Testing the new tag/widget ==
See [[Nasal Console]]
+
Okay, let's create a simple PUI/XML dialog from scratch using the new (unsupported!) {{tag|image}} tag. Use the [[Nasal Console]] to test the following:
 
<syntaxhighlight lang="nasal">
 
<syntaxhighlight lang="nasal">
 
var name = "test";
 
var name = "test";
Line 42: Line 42:
 
<syntaxhighlight lang="diff">
 
<syntaxhighlight lang="diff">
 
</syntaxhighlight>
 
</syntaxhighlight>
 
  
 
== Related ==
 
== Related ==
 
{{Appendix}}
 
{{Appendix}}

Revision as of 17:17, 11 March 2018

This article is a stub. You can help the wiki by expanding it.

Registering the pre-processor

Note  This works analogous to the existing addcommand() API - but it will be treated like an fgcommand based pre-processor that gets a handle to the widgets props.Node via the cmdarg() API. That way, the whole thing is mutable, too. In other words, the following 5 lines of code can be used to customize widgets and create entirely new ones in scripting space.
fgcommand("register-widget", props.Node.new({
 "module": "ui",
 "name": "image",
 "script": "props.dump( cmdarg() );"
}));

Testing the new tag/widget

Okay, let's create a simple PUI/XML dialog from scratch using the new (unsupported!) <image> tag. Use the Nasal Console to test the following:

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