Fix popupTip handling
delay argument was being ignored and popdown didn't work anymore.
This commit is contained in:
parent
6ca29b6fe9
commit
b4675c62b2
2 changed files with 11 additions and 14 deletions
|
@ -1,4 +1,6 @@
|
|||
var Tooltip = {
|
||||
# default delay (in seconds)
|
||||
DELAY: 4.0,
|
||||
# Constructor
|
||||
#
|
||||
# @param size ([width, height])
|
||||
|
@ -24,7 +26,7 @@ var Tooltip = {
|
|||
m.setInt("size[1]", size[1]);
|
||||
m.setBool("visible", 0);
|
||||
|
||||
m._hideTimer = maketimer(1.0, m, Tooltip._hideTimeout);
|
||||
m._hideTimer = maketimer(m.DELAY, m, Tooltip._hideTimeout);
|
||||
m._hideTimer.singleShot = 1;
|
||||
|
||||
return m;
|
||||
|
@ -215,13 +217,13 @@ var Tooltip = {
|
|||
}
|
||||
},
|
||||
|
||||
showMessage: func()
|
||||
showMessage: func(timeout = nil)
|
||||
{
|
||||
me.setInt("y", getprop('/sim/startup/ysize') * 0.2);
|
||||
var screenW = getprop('/sim/startup/xsize');
|
||||
me.setInt("x", (screenW - me._width) * 0.5);
|
||||
me.show();
|
||||
me._hideTimer.restart(4.0);
|
||||
me._hideTimer.restart(timeout or me.DELAY);
|
||||
},
|
||||
|
||||
hide: func()
|
||||
|
@ -344,7 +346,9 @@ var showMessage = func(node)
|
|||
var msgId = node.getNode("id");
|
||||
tooltip.setTooltipId((msgId == nil) ? 'msg' : msgId.getValue());
|
||||
innerSetTooltip(node);
|
||||
tooltip.showMessage();
|
||||
|
||||
var timeout = node.getNode("delay");
|
||||
tooltip.showMessage( timeout != nil ? timeout.getValue() : nil );
|
||||
}
|
||||
|
||||
var clearMessage = func(node)
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
##
|
||||
# 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. The third argument can be a hash with override values.
|
||||
# seconds can be specified as the second argument. The default is 4
|
||||
# seconds. The third argument can be a hash with override values.
|
||||
# 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. :)
|
||||
|
@ -116,7 +116,6 @@ var findElementByName = func(dialog,name) {
|
|||
#
|
||||
var fdm = getprop("/sim/flight-model");
|
||||
var screenHProp = nil;
|
||||
var tipArg = nil;
|
||||
var autopilotDisableProps = [
|
||||
"/autopilot/hide-menu",
|
||||
"/autopilot/KAP140/locks",
|
||||
|
@ -126,7 +125,6 @@ var autopilotDisableProps = [
|
|||
|
||||
_setlistener("/sim/signals/nasal-dir-initialized", func {
|
||||
screenHProp = props.globals.getNode("/sim/startup/ysize");
|
||||
tipArg = props.Node.new({ "dialog-name" : "PopTip" });
|
||||
|
||||
props.globals.getNode("/sim/help/debug", 1).setValues(debug_keys);
|
||||
props.globals.getNode("/sim/help/basic", 1).setValues(basic_keys);
|
||||
|
@ -224,15 +222,10 @@ var latencyDisplay = func(n) {
|
|||
fgcommand(w ? "dialog-show" : "dialog-close", props.Node.new({"dialog-name": "frame-latency"}));
|
||||
}
|
||||
|
||||
##
|
||||
# How many seconds do we show the tip?
|
||||
#
|
||||
var DELAY = 1.0;
|
||||
|
||||
##
|
||||
# Pop down the tip dialog, if it is visible.
|
||||
#
|
||||
var popdown = func { fgcommand("dialog-close", tipArg); }
|
||||
var popdown = func { fgcommand("clear-message", props.Node.new({"id": canvas.tooltip.getTooltipId()})); }
|
||||
|
||||
# Marker for the "current" timer. This value gets stored in the
|
||||
# closure of the timer function, and is used to check that there
|
||||
|
|
Loading…
Add table
Reference in a new issue