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:
parent
bfcaec9ea2
commit
467b4eef16
2 changed files with 21 additions and 0 deletions
|
@ -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
|
||||
|
|
|
@ -273,6 +273,7 @@
|
|||
|
||||
<item>
|
||||
<label>Autopilot Settings (F11)</label>
|
||||
<name>autopilot-settings</name>
|
||||
<binding>
|
||||
<command>dialog-show</command>
|
||||
<dialog-name>autopilot</dialog-name>
|
||||
|
@ -378,6 +379,7 @@
|
|||
|
||||
<item>
|
||||
<label>Map</label>
|
||||
<name>map</name>
|
||||
<binding>
|
||||
<command>dialog-show</command>
|
||||
<dialog-name>map</dialog-name>
|
||||
|
@ -403,6 +405,7 @@
|
|||
|
||||
<item>
|
||||
<label>Radio Settings (F12)</label>
|
||||
<name>radio</name>
|
||||
<binding>
|
||||
<command>dialog-show</command>
|
||||
<dialog-name>radios</dialog-name>
|
||||
|
@ -411,6 +414,7 @@
|
|||
|
||||
<item>
|
||||
<label>GPS Settings</label>
|
||||
<name>gps</name>
|
||||
<binding>
|
||||
<command>dialog-show</command>
|
||||
<dialog-name>gps</dialog-name>
|
||||
|
|
Loading…
Add table
Reference in a new issue