1
0
Fork 0

Added possibility to specify position to gui.popupTip

This commit is contained in:
Nikolai V. Chr 2014-12-16 07:26:09 +01:00
parent 2c0513816c
commit 4b806a36c2
2 changed files with 24 additions and 9 deletions

View file

@ -229,11 +229,19 @@ var Tooltip = {
}
},
showMessage: func(timeout = nil)
showMessage: func(timeout = nil, node = nil)
{
if(var y = me._haveNode(node, 'y') != nil ) {
me.setInt("y", y);
} else {
me.setInt("y", getprop('/sim/startup/ysize') * 0.2);
}
if(var x = me._haveNode(node, 'x') != nil) {
me.setInt("x", x);
} else {
var screenW = getprop('/sim/startup/xsize');
me.setInt("x", (screenW - me._width) * 0.5);
}
me.show();
# https://code.google.com/p/flightgear-bugs/issues/detail?id=1273
# when tooltip is shown for some other reason, ensure it stays for
@ -243,6 +251,12 @@ var Tooltip = {
me._hideTimer.restart(timeout or me.DELAY);
},
_haveNode: func(node, key) {
if(node == nil ) return nil;
var value = num(node.getValue(key) );
return value;
},
hide: func()
{
# this gets run repeatedly during mouse-moves
@ -365,7 +379,7 @@ var showMessage = func(node)
innerSetTooltip(node);
var timeout = node.getNode("delay");
tooltip.showMessage( timeout != nil ? timeout.getValue() : nil );
tooltip.showMessage( timeout != nil ? timeout.getValue() : nil, node);
}
var clearMessage = func(node)

View file

@ -6,11 +6,12 @@
# comes along and wants to pop a tip up before your delay is finished,
# you lose. :)
#
var popupTip = func(label, delay = nil, override = nil)
var popupTip = func(label, delay = nil, override = nil, position = nil)
{
fgcommand("show-message", props.Node.new({ "label": label, "delay":delay }));
if (position == nil) {
position = {};
}
fgcommand("show-message", props.Node.new({ "label": label, "delay":delay, "x": position['x'], "y": position['y'] }));
}
var showDialog = func(name) {