Add treenode.OnOpen and treenode.OnClose event callbacks

This commit is contained in:
Kenny Shields 2014-07-01 21:04:58 -04:00
parent c1d3021590
commit ec5d387927
2 changed files with 15 additions and 1 deletions

View File

@ -22,6 +22,8 @@ function newobject:initialize()
self.internal = true
self.internals = {}
self.icon = nil
self.OnOpen = nil
self.OnClose = nil
end

View File

@ -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