Fix minor tooltip bug

This commit is contained in:
Eduardo Bart 2012-08-19 06:13:37 -03:00
parent 0e3136f424
commit fb1c495a4c
1 changed files with 7 additions and 7 deletions

View File

@ -6,18 +6,18 @@ local toolTipLabel
local currentHoveredWidget local currentHoveredWidget
-- private functions -- private functions
local function moveToolTip(tooltip) local function moveToolTip(first)
if not tooltip:isVisible() or tooltip:getOpacity() < 0.1 then return end if not first and (not toolTipLabel:isVisible() or toolTipLabel:getOpacity() < 0.1) then return end
local pos = g_window.getMousePosition() local pos = g_window.getMousePosition()
pos.y = pos.y + 1 pos.y = pos.y + 1
local xdif = g_window.getSize().width - (pos.x + tooltip:getWidth()) local xdif = g_window.getSize().width - (pos.x + toolTipLabel:getWidth())
if xdif < 2 then if xdif < 2 then
pos.x = pos.x - tooltip:getWidth() - 3 pos.x = pos.x - toolTipLabel:getWidth() - 3
else else
pos.x = pos.x + 10 pos.x = pos.x + 10
end end
tooltip:setPosition(pos) toolTipLabel:setPosition(pos)
end end
local function onWidgetHoverChange(widget, hovered) local function onWidgetHoverChange(widget, hovered)
@ -51,7 +51,7 @@ function g_tooltip.init()
toolTipLabel:setBackgroundColor('#111111cc') toolTipLabel:setBackgroundColor('#111111cc')
toolTipLabel:setTextAlign(AlignCenter) toolTipLabel:setTextAlign(AlignCenter)
toolTipLabel:hide() toolTipLabel:hide()
toolTipLabel.onMouseMove = moveToolTip toolTipLabel.onMouseMove = function() moveToolTip() end
end) end)
end end
@ -77,7 +77,7 @@ function g_tooltip.display(text)
toolTipLabel:raise() toolTipLabel:raise()
toolTipLabel:enable() toolTipLabel:enable()
g_effects.fadeIn(toolTipLabel, 100) g_effects.fadeIn(toolTipLabel, 100)
moveToolTip(toolTipLabel) moveToolTip(true)
end end
function g_tooltip.hide() function g_tooltip.hide()