diff --git a/demo/pop/elements/element.lua b/demo/pop/elements/element.lua index f2651b4..1bbba88 100644 --- a/demo/pop/elements/element.lua +++ b/demo/pop/elements/element.lua @@ -235,6 +235,12 @@ do self.y = self.parent.y + self.margin self.w = self.parent.w - self.margin * 2 self.h = self.parent.h - self.margin * 2 + end, + delete = function(self) + for k, v in ipairs(self.child) do + v:delete() + end + return self.parent:removeChild(self) end } _base_0.__index = _base_0 diff --git a/lib/pop/elements/element.lua b/lib/pop/elements/element.lua index f2651b4..1bbba88 100644 --- a/lib/pop/elements/element.lua +++ b/lib/pop/elements/element.lua @@ -235,6 +235,12 @@ do self.y = self.parent.y + self.margin self.w = self.parent.w - self.margin * 2 self.h = self.parent.h - self.margin * 2 + end, + delete = function(self) + for k, v in ipairs(self.child) do + v:delete() + end + return self.parent:removeChild(self) end } _base_0.__index = _base_0 diff --git a/src/pop/elements/element.moon b/src/pop/elements/element.moon index 9f6db91..80dfcec 100644 --- a/src/pop/elements/element.moon +++ b/src/pop/elements/element.moon @@ -253,3 +253,9 @@ class element @y = @parent.y + @margin @w = @parent.w - @margin*2 @h = @parent.h - @margin*2 + + delete: => + for k,v in ipairs @child + v\delete! + + @parent\removeChild @