This commit is contained in:
Insality 2025-03-16 02:24:47 +02:00
parent a2bb93a03b
commit ad0447b649
16 changed files with 32 additions and 16 deletions

View File

@ -92,6 +92,18 @@ function M:on_style_change(style)
end
---@return druid.button self
function M:set_animations_disabled()
self.style.on_click = function() end
self.style.on_click_disabled = function() end
self.style.on_mouse_hover = function() end
self.style.on_hover = function() end
self.style.on_set_enabled = function() end
return self
end
function M:on_late_init()
if not self.click_zone then
local stencil_node = helper.get_closest_stencil_node(self.node)

View File

@ -9,8 +9,8 @@ local component = require("druid.component")
---@class druid.hover: druid.component
---@field node node
---@field on_hover event
---@field on_mouse_hover event
---@field on_hover event fun(self: druid.hover, is_hover: boolean)
---@field on_mouse_hover event fun(self: druid.hover, is_hover: boolean)
---@field style druid.hover.style
---@field click_zone node
---@field private _is_hovered boolean|nil

View File

@ -113,8 +113,8 @@ end
---Get a binded widget to the current game object.
---@generic T: druid.widget
---@param widget_class T The class of the widget to return
---@param gui_url_string string GUI url, if nil current gui will be used
---@return T|nil
---@param gui_url_string string? GUI url, if nil current gui will be used
---@return T
function M.get_widget(widget_class, gui_url_string)
local gui_url = msg.url(gui_url_string)
local guis = REGISTERED_GUI_WIDGETS[gui_url.socket]
@ -135,7 +135,7 @@ end
---Register a widget to the current game object.
---@param druid druid.instance The druid instance to register
function M.register_gui_widget(druid)
function M.register_druid_as_widget(druid)
local gui_url = msg.url()
REGISTERED_GUI_WIDGETS[gui_url.socket] = REGISTERED_GUI_WIDGETS[gui_url.socket] or {}
table.insert(REGISTERED_GUI_WIDGETS[gui_url.socket], {
@ -147,4 +147,5 @@ function M.register_gui_widget(druid)
})
end
return M

View File

@ -3,7 +3,7 @@ local druid = require("druid.druid")
function init(self)
self.druid = druid.new(self)
druid.register_gui_widget(self.druid)
druid.register_druid_as_widget(self.druid)
end

View File

@ -14,13 +14,13 @@ local utf8 = utf8 or utf8_lua
---@field on_input_wrong fun(self: druid.input, button_node: node) Callback on wrong user input
---@class druid.input: druid.component
---@field on_input_select event
---@field on_input_unselect event
---@field on_input_text event
---@field on_input_empty event
---@field on_input_full event
---@field on_input_wrong event
---@field on_select_cursor_change event
---@field on_input_select event fun(self: druid.input, input: druid.input)
---@field on_input_unselect event fun(self: druid.input, text: string, input: druid.input)
---@field on_input_text event fun(self: druid.input)
---@field on_input_empty event fun(self: druid.input)
---@field on_input_full event fun(self: druid.input)
---@field on_input_wrong event fun(self: druid.input)
---@field on_select_cursor_change event fun(self: druid.input, cursor_index: number, start_index: number, end_index: number)
---@field style table
---@field text druid.text
local M = component.create("input")

View File

@ -700,7 +700,7 @@ end
local hotkey = require("druid.extended.hotkey")
---Create Hotkey component
---@param keys_array string|string[] Keys for trigger action. Should contains one action key and any amount of modificator keys
---@param callback function|nil The callback function
---@param callback function|event|nil The callback function
---@param callback_argument any|nil The argument to pass into the callback function
---@return druid.hotkey component Hotkey component
function M:new_hotkey(keys_array, callback, callback_argument)

View File

@ -30,14 +30,16 @@ function M:set_text_property(text)
end
---@param text string
---@param text string|number
---@return widget.property_input
function M:set_text_value(text)
self.rich_input:set_text(text)
self.rich_input:set_text(tostring(text))
return self
end
---@param callback fun(self: widget.property_input, text: string)
---@param callback_context any
function M:on_change(callback, callback_context)
self.rich_input.input.on_input_unselect:subscribe(callback, callback_context)
end

View File

@ -8,6 +8,7 @@ local helper = require("druid.helper")
---@field text_name druid.text
---@field text_value druid.text
---@field slider druid.slider
---@field on_change_value event fun(value:number)
local M = {}