From 7451bd5863b3498d3de0e295080dbd77fa2ee6e9 Mon Sep 17 00:00:00 2001 From: Kenny Shields Date: Sat, 20 Sep 2014 10:58:36 -0400 Subject: [PATCH] Open/close treenodes when they are left-clicked --- objects/internal/treenode.lua | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/objects/internal/treenode.lua b/objects/internal/treenode.lua index 07321fa..281ef69 100644 --- a/objects/internal/treenode.lua +++ b/objects/internal/treenode.lua @@ -18,6 +18,7 @@ function newobject:initialize() self.height = 16 self.level = 0 self.leftpadding = 0 + self.lastclick = 0 self.open = false self.internal = true self.internals = {} @@ -153,6 +154,11 @@ function newobject:mousepressed(x, y, button) end 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 self.tree.selectednode = self if onselectnode then