1
0
Fork 0

- fix bug that made gui.popupTip() ignore the optional delay argument

- use more "var" keywords and named args
- popupTip(): add optional third hash argument that is merged with the
  dialog properies hash. This can be used to select different font or
  dialog colors, etc.
This commit is contained in:
mfranz 2007-11-09 13:00:05 +00:00
parent 56eb66f03b
commit 5481c73b20

View file

@ -1,38 +1,40 @@
## ##
# Pop up a "tip" dialog for a moment, then remove it. The delay in # Pop up a "tip" dialog for a moment, then remove it. The delay in
# seconds can be specified as the second argument. The default is 1 # seconds can be specified as the second argument. The default is 1
# second. Note that the tip dialog is a shared resource. If # second. The third argument can be a hash with override values.
# someone else comes along and wants to pop a tip up before your delay # Note that the tip dialog is a shared resource. If someone else
# is finished, you lose. :) # comes along and wants to pop a tip up before your delay is finished,
# you lose. :)
# #
popupTip = func { var popupTip = func(label, delay = nil, override = nil) {
delay = if(size(arg) > 1) {arg[1]} else {DELAY}; var tmpl = props.Node.new({
tmpl = { name : "PopTip", modal : 0, layout : "hbox", name : "PopTip", modal : 0, layout : "hbox",
y: screenHProp.getValue() - 140, y: screenHProp.getValue() - 140,
text : { label : arg[0], padding : 6 } }; text : { label : label, padding : 6 }
});
if (override != nil) tmpl.setValues(override);
popdown(); popdown();
fgcommand("dialog-new", props.Node.new(tmpl)); fgcommand("dialog-new", tmpl);
fgcommand("dialog-show", tipArg); fgcommand("dialog-show", tipArg);
currTimer = currTimer + 1; currTimer += 1;
thisTimer = currTimer; var thisTimer = currTimer;
# Final argument is a flag to use "real" time, not simulated time # Final argument is a flag to use "real" time, not simulated time
settimer(func { if(currTimer == thisTimer) { popdown() } }, DELAY, 1); settimer(func { if(currTimer == thisTimer) { popdown() } }, delay or DELAY, 1);
} }
showDialog = func { var showDialog = func(name) {
fgcommand("dialog-show", fgcommand("dialog-show", props.Node.new({ "dialog-name" : name }));
props.Node.new({ "dialog-name" : arg[0]}));
} }
## ##
# Enable/disable named menu entry # Enable/disable named menu entry
# #
menuEnable = func(searchname, state) { var menuEnable = func(searchname, state) {
foreach (menu; props.globals.getNode("/sim/menubar/default").getChildren("menu")) { foreach (var menu; props.globals.getNode("/sim/menubar/default").getChildren("menu")) {
foreach (name; menu.getChildren("name")) { foreach (var name; menu.getChildren("name")) {
if (name.getValue() == searchname) { if (name.getValue() == searchname) {
menu.getNode("enabled").setBoolValue(state); menu.getNode("enabled").setBoolValue(state);
} }