mirror of
https://github.com/Insality/druid
synced 2025-09-27 18:12:21 +02:00
Remove html api, update docs
This commit is contained in:
@@ -15,14 +15,29 @@ local component = require("druid.component")
|
||||
---@field on_mouse_hover fun(self, node, hover_state)|nil
|
||||
---@field on_set_enabled fun(self, node, enabled_state)|nil
|
||||
|
||||
---Druid component to make clickable node with various interaction callbacks
|
||||
---Basic Druid input component. Handle input on node and provide different callbacks on touch events.
|
||||
---
|
||||
---### Setup
|
||||
---Create button with druid: `button = druid:new_button(node_name, callback, [params], [animation_node])`
|
||||
---Where node_name is name of node from GUI scene. You can use `node_name` as input trigger zone and point another node for animation via `animation_node`
|
||||
---
|
||||
---### Notes
|
||||
---- Button callback have next params: (self, params, button_instance)
|
||||
---- - **self** - Druid self context
|
||||
---- - **params** - Additional params, specified on button creating
|
||||
---- - **button_instance** - button itself
|
||||
---- You can set _params_ on button callback on button creating: `druid:new_button("node_name", callback, params)`.
|
||||
---- Button have several events like on_click, on_repeated_click, on_long_click, on_hold_click, on_double_click
|
||||
---- Click event will not trigger if between pressed and released state cursor was outside of node zone
|
||||
---- Button can have key trigger to use them by key: `button:set_key_trigger`
|
||||
----
|
||||
---@class druid.button: druid.component
|
||||
---@field on_click event function(self, custom_args, button_instance)
|
||||
---@field on_pressed event function(self, custom_args, button_instance)
|
||||
---@field on_repeated_click event function(self, custom_args, button_instance, click_count)
|
||||
---@field on_long_click event function(self, custom_args, button_instance, hold_time)
|
||||
---@field on_double_click event function(self, custom_args, button_instance, click_amount)
|
||||
---@field on_hold_callback event function(self, custom_args, button_instance, press_time)
|
||||
---@field on_repeated_click event function(self, custom_args, button_instance, click_count) Repeated click callback, while holding the button
|
||||
---@field on_long_click event function(self, custom_args, button_instance, hold_time) Callback on long button tap
|
||||
---@field on_double_click event function(self, custom_args, button_instance, click_amount) Different callback, if tap button 2+ in row
|
||||
---@field on_hold_callback event function(self, custom_args, button_instance, press_time) Hold callback, before long_click trigger
|
||||
---@field on_click_outside event function(self, custom_args, button_instance)
|
||||
---@field node node Clickable node
|
||||
---@field node_id hash Node id
|
||||
@@ -41,8 +56,8 @@ local M = component.create("button")
|
||||
---The constructor for the button component
|
||||
---@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
|
||||
---@param anim_node node|string|nil Node to animate instead of trigger node
|
||||
---@param custom_args any|nil Custom args for any Button event, will be passed to callbacks
|
||||
---@param anim_node node|string|nil Node to animate instead of trigger node, useful for animating small icons on big panels
|
||||
function M:init(node_or_node_id, callback, custom_args, anim_node)
|
||||
self.druid = self:get_druid()
|
||||
self.node = self:get_node(node_or_node_id)
|
||||
|
Reference in New Issue
Block a user