Howto:Hooking into the GUI: Difference between revisions
Jump to navigation
Jump to search
(→Status) |
|||
Line 8: | Line 8: | ||
== C++ Patches == | == 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. | |||
<syntaxhighlight lang="diff"> | |||
</syntaxhighlight> | |||
== Registering the pre-processor == | == Registering the pre-processor == |
Revision as of 21:19, 11 March 2018
This article is a stub. You can help the wiki by expanding it. |
Objective
Status
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.
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);
Implementation details
Related
References
|