`toolbarview`: Remove tooltip when hidden (#1251)

This commit is contained in:
Guldoman 2022-12-20 23:07:29 +01:00 committed by GitHub
parent 3c64c32379
commit 213dc7142e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 8 additions and 0 deletions

View File

@ -39,6 +39,11 @@ end
function ToolbarView:toggle_visible() function ToolbarView:toggle_visible()
self.visible = not self.visible self.visible = not self.visible
if self.tooltip then
core.status_view:remove_tooltip()
self.tooltip = false
end
self.hovered_item = nil
end end
function ToolbarView:get_icon_width() function ToolbarView:get_icon_width()
@ -73,6 +78,7 @@ end
function ToolbarView:draw() function ToolbarView:draw()
if not self.visible then return end
self:draw_background(style.background2) self:draw_background(style.background2)
for item, x, y, w, h in self:each_item() do for item, x, y, w, h in self:each_item() do
@ -83,6 +89,7 @@ end
function ToolbarView:on_mouse_pressed(button, x, y, clicks) function ToolbarView:on_mouse_pressed(button, x, y, clicks)
if not self.visible then return end
local caught = ToolbarView.super.on_mouse_pressed(self, button, x, y, clicks) local caught = ToolbarView.super.on_mouse_pressed(self, button, x, y, clicks)
if caught then return caught end if caught then return caught end
core.set_active_view(core.last_active_view) core.set_active_view(core.last_active_view)
@ -94,6 +101,7 @@ end
function ToolbarView:on_mouse_moved(px, py, ...) function ToolbarView:on_mouse_moved(px, py, ...)
if not self.visible then return end
ToolbarView.super.on_mouse_moved(self, px, py, ...) ToolbarView.super.on_mouse_moved(self, px, py, ...)
self.hovered_item = nil self.hovered_item = nil
local x_min, x_max, y_min, y_max = self.size.x, 0, self.size.y, 0 local x_min, x_max, y_min, y_max = self.size.x, 0, self.size.y, 0