mirror of
https://github.com/Insality/druid.git
synced 2025-09-28 02:22:18 +02:00
#111 Add druid.stencil_check for auto stencil check to call set_click_zone
This commit is contained in:
@@ -57,7 +57,11 @@ local const = require("druid.const")
|
||||
local helper = require("druid.helper")
|
||||
local component = require("druid.component")
|
||||
|
||||
local Button = component.create("button", { component.ON_INPUT, component.ON_MESSAGE_INPUT })
|
||||
local Button = component.create("button", {
|
||||
component.ON_INPUT,
|
||||
component.ON_MESSAGE_INPUT,
|
||||
component.ON_LATE_INIT
|
||||
})
|
||||
|
||||
|
||||
local function is_input_match(self, action_id)
|
||||
@@ -221,6 +225,16 @@ function Button.init(self, node, callback, params, anim_node)
|
||||
end
|
||||
|
||||
|
||||
function Button.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)
|
||||
if stencil_node then
|
||||
self:set_click_zone(stencil_node)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
function Button.on_input(self, action_id, action)
|
||||
if not is_input_match(self, action_id) then
|
||||
return false
|
||||
|
Reference in New Issue
Block a user