1
0
Fork 0

Add function to allow the binding of a menu item to be configured

through Nasal using a symbolic name.

Usage:

gui.menuBind("radio", "dialogs.Radio.open()");
This commit is contained in:
Stuart Buchanan 2011-01-03 17:28:40 +00:00
parent bfcaec9ea2
commit 467b4eef16
2 changed files with 21 additions and 0 deletions

View file

@ -49,6 +49,23 @@ var menuEnable = func(searchname, state) {
} }
} }
##
# Set the binding for a menu item to a Nasal script,
# typically a dialog open() command.
#
var menuBind = func(searchname, command) {
foreach (var menu; props.globals.getNode("/sim/menubar/default").getChildren("menu")) {
foreach (item; menu.getChildren("item")) {
foreach (name; item.getChildren("name")) {
if (name.getValue() == searchname) {
item.getNode("binding", 1).getNode("command", 1).setValue("nasal");
item.getNode("binding", 1).getNode("script", 1).setValue(command);
fgcommand("gui-redraw");
}
}
}
}
}
## ##
# Set mouse cursor coordinates and shape (number or name), and return # Set mouse cursor coordinates and shape (number or name), and return

View file

@ -273,6 +273,7 @@
<item> <item>
<label>Autopilot Settings (F11)</label> <label>Autopilot Settings (F11)</label>
<name>autopilot-settings</name>
<binding> <binding>
<command>dialog-show</command> <command>dialog-show</command>
<dialog-name>autopilot</dialog-name> <dialog-name>autopilot</dialog-name>
@ -378,6 +379,7 @@
<item> <item>
<label>Map</label> <label>Map</label>
<name>map</name>
<binding> <binding>
<command>dialog-show</command> <command>dialog-show</command>
<dialog-name>map</dialog-name> <dialog-name>map</dialog-name>
@ -403,6 +405,7 @@
<item> <item>
<label>Radio Settings (F12)</label> <label>Radio Settings (F12)</label>
<name>radio</name>
<binding> <binding>
<command>dialog-show</command> <command>dialog-show</command>
<dialog-name>radios</dialog-name> <dialog-name>radios</dialog-name>
@ -411,6 +414,7 @@
<item> <item>
<label>GPS Settings</label> <label>GPS Settings</label>
<name>gps</name>
<binding> <binding>
<command>dialog-show</command> <command>dialog-show</command>
<dialog-name>gps</dialog-name> <dialog-name>gps</dialog-name>