diff --git a/objects/internal/treenode.lua b/objects/internal/treenode.lua index 5757c7d..23a2cad 100644 --- a/objects/internal/treenode.lua +++ b/objects/internal/treenode.lua @@ -22,6 +22,8 @@ function newobject:initialize() self.internal = true self.internals = {} self.icon = nil + self.OnOpen = nil + self.OnClose = nil end diff --git a/objects/internal/treenodebutton.lua b/objects/internal/treenodebutton.lua index dc55e8d..ae203e8 100644 --- a/objects/internal/treenodebutton.lua +++ b/objects/internal/treenodebutton.lua @@ -120,7 +120,19 @@ function newobject:mousepressed(x, y, button) local hover = self.hover if hover and button == "l" then - self.parent:SetOpen(not self.parent.open) + local bool = not self.parent.open + if bool then + local onopen = self.parent.OnOpen + if onopen then + onopen(self.parent) + end + else + local onclose = self.parent.OnClose + if onclose then + onclose(self.parent) + end + end + self.parent:SetOpen(bool) print("!") print(self.parent.level) end