This commit is contained in:
Insality
2025-03-05 22:06:06 +02:00
parent d6bec60ba9
commit 46223f0bb8
11 changed files with 557 additions and 628 deletions

View File

@@ -39,23 +39,6 @@ local component = require("druid.component")
local M = component.create("button")
---@param style druid.button.style
function M:on_style_change(style)
self.style = {
LONGTAP_TIME = style.LONGTAP_TIME or 0.4,
AUTOHOLD_TRIGGER = style.AUTOHOLD_TRIGGER or 0.8,
DOUBLETAP_TIME = style.DOUBLETAP_TIME or 0.4,
on_click = style.on_click or function(_, node) end,
on_click_disabled = style.on_click_disabled or function(_, node) end,
on_mouse_hover = style.on_mouse_hover or function(_, node, state) end,
on_hover = style.on_hover or function(_, node, state) end,
on_set_enabled = style.on_set_enabled or function(_, node, state) end,
}
end
---Button constructor
---@param node_or_node_id node|string Node name or GUI Node itself
---@param callback fun()|nil Callback on button click
---@param custom_args any|nil Custom args for any Button event
@@ -94,6 +77,22 @@ function M:init(node_or_node_id, callback, custom_args, anim_node)
end
---@param style druid.button.style
function M:on_style_change(style)
self.style = {
LONGTAP_TIME = style.LONGTAP_TIME or 0.4,
AUTOHOLD_TRIGGER = style.AUTOHOLD_TRIGGER or 0.8,
DOUBLETAP_TIME = style.DOUBLETAP_TIME or 0.4,
on_click = style.on_click or function(_, node) end,
on_click_disabled = style.on_click_disabled or function(_, node) end,
on_mouse_hover = style.on_mouse_hover or function(_, node, state) end,
on_hover = style.on_hover or function(_, node, state) end,
on_set_enabled = style.on_set_enabled or function(_, node, state) end,
}
end
function M:on_late_init()
if not self.click_zone then
local stencil_node = helper.get_closest_stencil_node(self.node)