Open/close treenodes when they are left-clicked

This commit is contained in:
Kenny Shields 2014-09-20 10:58:36 -04:00
parent 3493e78813
commit 7451bd5863

View File

@ -18,6 +18,7 @@ function newobject:initialize()
self.height = 16 self.height = 16
self.level = 0 self.level = 0
self.leftpadding = 0 self.leftpadding = 0
self.lastclick = 0
self.open = false self.open = false
self.internal = true self.internal = true
self.internals = {} self.internals = {}
@ -153,6 +154,11 @@ function newobject:mousepressed(x, y, button)
end end
if self.hover and button == "l" then if self.hover and button == "l" then
local time = os.time()
if self.lastclick + 0.40 > time then
self.open = not self.open
end
self.lastclick = time
local onselectnode = self.tree.OnSelectNode local onselectnode = self.tree.OnSelectNode
self.tree.selectednode = self self.tree.selectednode = self
if onselectnode then if onselectnode then