Merge pull request #870 from lite-xl/treeview-fix

plugin treeview: skip rootview events if not visible.
This commit is contained in:
Jefferson González 2022-03-07 18:50:36 -04:00 committed by GitHub
commit 52a47e0d73
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 5 additions and 0 deletions

View File

@ -186,6 +186,7 @@ end
function TreeView:on_mouse_moved(px, py, ...) function TreeView:on_mouse_moved(px, py, ...)
if not self.visible then return end
TreeView.super.on_mouse_moved(self, px, py, ...) TreeView.super.on_mouse_moved(self, px, py, ...)
if self.dragging_scrollbar then return end if self.dragging_scrollbar then return end
@ -223,6 +224,7 @@ end
function TreeView:on_mouse_pressed(button, x, y, clicks) function TreeView:on_mouse_pressed(button, x, y, clicks)
if not self.visible then return end
local caught = TreeView.super.on_mouse_pressed(self, button, x, y, clicks) local caught = TreeView.super.on_mouse_pressed(self, button, x, y, clicks)
if caught or button ~= "left" then if caught or button ~= "left" then
return true return true
@ -263,6 +265,8 @@ function TreeView:update()
self:move_towards(self.size, "x", dest) self:move_towards(self.size, "x", dest)
end end
if not self.visible then return end
local duration = system.get_time() - self.tooltip.begin local duration = system.get_time() - self.tooltip.begin
if self.hovered_item and self.tooltip.x and duration > tooltip_delay then if self.hovered_item and self.tooltip.x and duration > tooltip_delay then
self:move_towards(self.tooltip, "alpha", tooltip_alpha, tooltip_alpha_rate) self:move_towards(self.tooltip, "alpha", tooltip_alpha, tooltip_alpha_rate)
@ -372,6 +376,7 @@ end
function TreeView:draw() function TreeView:draw()
if not self.visible then return end
self:draw_background(style.background2) self:draw_background(style.background2)
local _y, _h = self.position.y, self.size.y local _y, _h = self.position.y, self.size.y