Skip to content

Commit a2b2737

Browse files
committed
Add on_change_value to input property widget
1 parent 2b68117 commit a2b2737

File tree

2 files changed

+12
-0
lines changed

2 files changed

+12
-0
lines changed

api/components/widgets/properties_panel/property_input_api.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
- [druid](#druid)
1919
- [selected](#selected)
2020
- [rich_input](#rich_input)
21+
- [on_change_value](#on_change_value)
2122

2223

2324

@@ -88,3 +89,5 @@ property_input:on_change(callback, [callback_context])
8889
<a name="rich_input"></a>
8990
- **rich_input** (_druid.rich_input_): The component that handles a rich text input field, it's a wrapper around the druid.input component
9091

92+
<a name="on_change_value"></a>
93+
- **on_change_value** (_event.event_): fun(text) Event triggered when the value of the input changes.

druid/widget/properties_panel/properties/property_input.lua

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,12 @@
1+
local event = require("event.event")
2+
13
---@class druid.widget.property_input: druid.widget
24
---@field root node
35
---@field container druid.container
46
---@field text_name druid.text
57
---@field button druid.button
68
---@field druid druid.instance
9+
---@field on_change_value event fun(text: string)
710
local M = {}
811

912
function M:init()
@@ -19,6 +22,12 @@ function M:init()
1922
self.container = self.druid:new_container(self.root)
2023
self.container:add_container("text_name")
2124
self.container:add_container("E_Anchor")
25+
26+
self.on_change_value = event.create()
27+
28+
self.rich_input.input.on_input_unselect:subscribe(function(_, text)
29+
self.on_change_value:trigger(text)
30+
end)
2231
end
2332

2433

0 commit comments

Comments
 (0)