Fix the flashing tooltip issue

This commit is contained in:
Francesco Abbate
2021-02-21 11:09:51 +01:00
parent 2353076b37
commit fc46946ea1
2 changed files with 18 additions and 7 deletions
+6 -1
View File
@@ -88,7 +88,10 @@ end
function ToolbarView:on_mouse_moved(px, py, ...)
ToolbarView.super.on_mouse_moved(self, px, py, ...)
self.hovered_item = nil
local x_min, x_max, y_min, y_max = self.size.x, 0, self.size.y, 0
for item, x, y, w, h in self:each_item() do
x_min, x_max = math.min(x, x_min), math.max(x + w, x_max)
y_min, y_max = y, y + h
if px > x and py > y and px <= x + w and py <= y + h then
self.hovered_item = item
core.status_view:show_tooltip(command.prettify_name(item.command))
@@ -96,7 +99,9 @@ function ToolbarView:on_mouse_moved(px, py, ...)
return
end
end
if self.tooltip then
if px > x_min and px <= x_max and py > y_min and py <= y_max then
self.tooltip = true
elseif self.tooltip then
core.status_view:remove_tooltip()
self.tooltip = false
end