2003-12-22 20:05:18 +00:00
|
|
|
##
|
|
|
|
# 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
|
|
|
|
# second. Note that the tip dialog is a shared resource. If
|
|
|
|
# someone else comes along and wants to pop a tip up before your delay
|
|
|
|
# is finished, you lose. :)
|
|
|
|
#
|
|
|
|
popupTip = func {
|
|
|
|
delay = if(size(arg) > 1) {arg[1]} else {DELAY};
|
2004-05-12 18:41:29 +00:00
|
|
|
tmpl = { name : "PopTip", modal : 0, layout : "hbox",
|
|
|
|
y: screenHProp.getValue() - 140,
|
|
|
|
text : { label : arg[0], padding : 6 } };
|
2003-12-22 20:05:18 +00:00
|
|
|
|
|
|
|
popdown();
|
2004-05-12 18:41:29 +00:00
|
|
|
fgcommand("dialog-new", props.Node.new(tmpl));
|
2003-12-22 20:05:18 +00:00
|
|
|
fgcommand("dialog-show", tipArg);
|
|
|
|
|
|
|
|
currTimer = currTimer + 1;
|
|
|
|
thisTimer = currTimer;
|
|
|
|
settimer(func { if(currTimer == thisTimer) { popdown() } }, DELAY);
|
|
|
|
}
|
|
|
|
|
|
|
|
########################################################################
|
|
|
|
# Private Stuff:
|
|
|
|
########################################################################
|
|
|
|
|
|
|
|
##
|
|
|
|
# Initialize property nodes via a timer, to insure the props module is
|
2004-05-12 18:41:29 +00:00
|
|
|
# loaded. See notes in view.nas. Simply cache the screen height
|
|
|
|
# property and the argument for the "dialog-show" command. This
|
|
|
|
# probably isn't really needed...
|
2003-12-22 20:05:18 +00:00
|
|
|
#
|
2004-05-12 18:41:29 +00:00
|
|
|
screenHProp = tipArg = nil;
|
2003-12-22 20:05:18 +00:00
|
|
|
INIT = func {
|
|
|
|
screenHProp = props.globals.getNode("/sim/startup/ysize");
|
|
|
|
tipArg = props.Node.new({ "dialog-name" : "PopTip" });
|
|
|
|
}
|
|
|
|
settimer(INIT, 0);
|
|
|
|
|
|
|
|
##
|
|
|
|
# How many seconds do we show the tip?
|
|
|
|
#
|
|
|
|
DELAY = 1.0;
|
|
|
|
|
|
|
|
##
|
|
|
|
# Pop down the tip dialog, if it is visible.
|
|
|
|
#
|
|
|
|
popdown = func { fgcommand("dialog-close", tipArg); }
|
|
|
|
|
|
|
|
# Marker for the "current" timer. This value gets stored in the
|
|
|
|
# closure of the timer function, and is used to check that there
|
|
|
|
# hasn't been a more recent timer set that should override.
|
|
|
|
currTimer = 0;
|