Howto:Creating a Canvas GUI dialog file: Difference between revisions
Jump to navigation
Jump to search
(Created page with "{{Stub}} {{Canvas Navigation}} == Editing Translations/en/menu.xml == Navigate to the sub-menu where you'd like to add your new dialog, e.g. "Equipment" in this case, and th...") |
mNo edit summary |
||
Line 54: | Line 54: | ||
Finally, start FlightGear and open your new dialog | Finally, start FlightGear and open your new dialog | ||
== Adding Widgets == | |||
== Using Layouts == |
Revision as of 16:24, 29 June 2014
This article is a stub. You can help the wiki by expanding it. |
The FlightGear forum has a subforum related to: Canvas |
Navigate to the sub-menu where you'd like to add your new dialog, e.g. "Equipment" in this case, and then add a key:
<equipment>Equipment</equipment>
<canvas-demo-dialog>Canvas Demo Dialog</canvas-demo-dialog>
Next, open $FG_ROOT/gui/menubar.xml and navigate to the corresponding sub-menu and add a new item/binding:
<item>
<name>canvas-demo-dialog</name>
<binding>
<command>nasal</command>
<script>
canvas.loadDialog("CanvasDemo");
</script>
</binding>
</item>
Next, open/create $FG_ROOT/Nasal/canvas/gui/dialogs/CanvasDemo.nas and add some boilerplate code:
var DemoDialog = {
new: func
{
var m = {
parents: [DemoDialog],
_dlg: canvas.Window.new([400,300], "dialog")
.set("title", "Demo Dialog")
.set("resize", 1),
_active_button: nil
};
m._dlg.getCanvas(1)
.set("background", canvas.style.getColor("bg_color"));
m._root = m._dlg.getCanvas().createGroup();
var vbox = VBoxLayout.new();
m._dlg.setLayout(vbox);
return m;
},
};
var demo = DemoDialog.new();
Finally, start FlightGear and open your new dialog