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

Howto:Hooking into the GUI

From FlightGear wiki
Revision as of 17:27, 11 March 2018 by Hooray (Talk | contribs) (C++ Patches)

Jump to: navigation, search
This article is a stub. You can help the wiki by expanding it.



working / proof-of-concept (03/2018)


  • 2 new fgcommands

C++ Patches

The following set of patches implements a very simple fgcommand-based pre-processor scheme implemented on top of the SGPropertyNode (property tree) structure. This hooks into the dialog building engine, i.e. after the layouting engine has pre-processed all widgets.

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. The preprocessor must be implemented as part of the script portion shown below. That way, the whole thing is mutable, too (i.e. it can add/remove and change nodes as necessary). 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 (procedurally) 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");

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

Alternatively, you can also use an XML file

Implementation details