Add on_change_value to input property widget

This commit is contained in:
Insality 2025-05-02 13:36:36 +03:00
parent 2b68117527
commit a2b273762d
2 changed files with 12 additions and 0 deletions

View File

@ -18,6 +18,7 @@
- [druid](#druid) - [druid](#druid)
- [selected](#selected) - [selected](#selected)
- [rich_input](#rich_input) - [rich_input](#rich_input)
- [on_change_value](#on_change_value)
@ -88,3 +89,5 @@ property_input:on_change(callback, [callback_context])
<a name="rich_input"></a> <a name="rich_input"></a>
- **rich_input** (_druid.rich_input_): The component that handles a rich text input field, it's a wrapper around the druid.input component - **rich_input** (_druid.rich_input_): The component that handles a rich text input field, it's a wrapper around the druid.input component
<a name="on_change_value"></a>
- **on_change_value** (_event.event_): fun(text) Event triggered when the value of the input changes.

View File

@ -1,9 +1,12 @@
local event = require("event.event")
---@class druid.widget.property_input: druid.widget ---@class druid.widget.property_input: druid.widget
---@field root node ---@field root node
---@field container druid.container ---@field container druid.container
---@field text_name druid.text ---@field text_name druid.text
---@field button druid.button ---@field button druid.button
---@field druid druid.instance ---@field druid druid.instance
---@field on_change_value event fun(text: string)
local M = {} local M = {}
function M:init() function M:init()
@ -19,6 +22,12 @@ function M:init()
self.container = self.druid:new_container(self.root) self.container = self.druid:new_container(self.root)
self.container:add_container("text_name") self.container:add_container("text_name")
self.container:add_container("E_Anchor") self.container:add_container("E_Anchor")
self.on_change_value = event.create()
self.rich_input.input.on_input_unselect:subscribe(function(_, text)
self.on_change_value:trigger(text)
end)
end end