Solve #182 add table pool for events

This commit is contained in:
Insality
2022-04-05 18:57:40 +03:00
parent 2779f9cf7a
commit dff522fbaa
24 changed files with 244 additions and 6 deletions

View File

@@ -30,6 +30,12 @@ function BackHandler.init(self, callback, params)
end
function BackHandler.on_internal_remove(self)
component.on_internal_remove(self)
self.on_back:clear()
end
--- Input handler for component
-- @tparam BackHandler self @{BackHandler}
-- @tparam string action_id on_input action id

View File

@@ -239,6 +239,17 @@ function Button.on_late_init(self)
end
function Button.on_internal_remove(self)
component.on_internal_remove(self)
self.on_click:clear()
self.on_repeated_click:clear()
self.on_long_click:clear()
self.on_double_click:clear()
self.on_hold_callback:clear()
self.on_click_outside:clear()
end
function Button.on_input(self, action_id, action)
if not is_input_match(self, action_id) then
return false

View File

@@ -189,6 +189,16 @@ function Drag.init(self, node, on_drag_callback)
end
function Drag.on_internal_remove(self)
component.on_internal_remove(self)
self.on_touch_start:clear()
self.on_touch_end:clear()
self.on_drag_start:clear()
self.on_drag:clear()
self.on_drag_end:clear()
end
function Drag.on_late_init(self)
if not self.click_zone and const.IS_STENCIL_CHECK then
local stencil_node = helper.get_closest_stencil_node(self.node)

View File

@@ -38,6 +38,13 @@ function Hover.init(self, node, on_hover_callback)
end
function Hover.on_internal_remove(self)
component.on_internal_remove(self)
self.on_hover:clear()
self.on_mouse_hover:clear()
end
function Hover.on_late_init(self)
if not self.click_zone and const.IS_STENCIL_CHECK then
local stencil_node = helper.get_closest_stencil_node(self.node)

View File

@@ -174,6 +174,14 @@ function Scroll.init(self, view_node, content_node)
end
function Scroll.on_internal_remove(self)
component.on_internal_remove(self)
self.on_scroll:clear()
self.on_scroll_to:clear()
self.on_point_scroll:clear()
end
function Scroll.on_late_init(self)
if not self.click_zone and const.IS_STENCIL_CHECK then
local stencil_node = helper.get_closest_stencil_node(self.node)

View File

@@ -115,6 +115,16 @@ function StaticGrid.init(self, parent, element, in_row)
end
function StaticGrid.on_internal_remove(self)
component.on_internal_remove(self)
self.on_add_item:clear()
self.on_remove_item:clear()
self.on_change_items:clear()
self.on_clear:clear()
self.on_update_positions:clear()
end
local _temp_pos = vmath.vector3(0)
--- Return pos for grid node index
-- @tparam StaticGrid self @{StaticGrid}

View File

@@ -99,6 +99,12 @@ function Swipe.init(self, node, on_swipe_callback)
end
function Swipe.on_internal_remove(self)
component.on_internal_remove(self)
self.on_swipe:clear()
end
function Swipe.on_late_init(self)
if not self.click_zone and const.IS_STENCIL_CHECK then
local stencil_node = helper.get_closest_stencil_node(self.node)

View File

@@ -217,6 +217,14 @@ function Text.init(self, node, value, adjust_type)
end
function Text.on_internal_remove(self)
component.on_internal_remove(self)
self.on_set_text:clear()
self.on_set_pivot:clear()
self.on_update_text_scale:clear()
end
function Text.on_layout_change(self)
self:set_to(self.last_value)
end