diff --git a/api/components/widgets/properties_panel/property_input_api.md b/api/components/widgets/properties_panel/property_input_api.md index eacb054..cfd31a1 100644 --- a/api/components/widgets/properties_panel/property_input_api.md +++ b/api/components/widgets/properties_panel/property_input_api.md @@ -18,6 +18,7 @@ - [druid](#druid) - [selected](#selected) - [rich_input](#rich_input) +- [on_change_value](#on_change_value) @@ -88,3 +89,5 @@ property_input:on_change(callback, [callback_context]) - **rich_input** (_druid.rich_input_): The component that handles a rich text input field, it's a wrapper around the druid.input component + +- **on_change_value** (_event.event_): fun(text) Event triggered when the value of the input changes. diff --git a/druid/widget/properties_panel/properties/property_input.lua b/druid/widget/properties_panel/properties/property_input.lua index c33bb1b..76d1e96 100644 --- a/druid/widget/properties_panel/properties/property_input.lua +++ b/druid/widget/properties_panel/properties/property_input.lua @@ -1,9 +1,12 @@ +local event = require("event.event") + ---@class druid.widget.property_input: druid.widget ---@field root node ---@field container druid.container ---@field text_name druid.text ---@field button druid.button ---@field druid druid.instance +---@field on_change_value event fun(text: string) local M = {} function M:init() @@ -19,6 +22,12 @@ function M:init() self.container = self.druid:new_container(self.root) self.container:add_container("text_name") 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