File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -5555,7 +5555,7 @@ TextArea Attributes:
55555555 Functions similarly to the ``ignore_keys `` attribute in the ``EditField `` class.
55565556
55575557* ``on_text_change ``: Callback function called whenever the text changes.
5558- The function signature should be ``on_text_change(new_text) ``.
5558+ The function signature should be ``on_text_change(new_text, old_text ) ``.
55595559
55605560* ``on_cursor_change ``: Callback function called whenever the cursor position changes.
55615561 Expected function signature is ``on_cursor_change(new_cursor, old_cursor) ``.
Original file line number Diff line number Diff line change @@ -34,10 +34,10 @@ function TextArea:init()
3434 debug = self .debug ,
3535 one_line_mode = self .one_line_mode ,
3636
37- on_text_change = function (val )
37+ on_text_change = function (text , old_text )
3838 self :updateLayout ()
3939 if self .on_text_change then
40- self .on_text_change (val )
40+ self .on_text_change (text , old_text )
4141 end
4242 end ,
4343 on_cursor_change = self :callback (' onCursorChange' )
Original file line number Diff line number Diff line change @@ -189,13 +189,14 @@ function TextAreaContent:paste()
189189end
190190
191191function TextAreaContent :setText (text )
192- local changed = self .text ~= text
192+ local old_text = self .text
193+
193194 self .text = self :normalizeText (text )
194195
195196 self :recomputeLines ()
196197
197- if changed and self .on_text_change then
198- self .on_text_change (text )
198+ if self .on_text_change and text ~= old_text then
199+ self .on_text_change (text , old_text )
199200 end
200201end
201202
You can’t perform that action at this time.
0 commit comments