slint icon indicating copy to clipboard operation
slint copied to clipboard

TextInput: add API to get and set the selection

Open ogoffart opened this issue 1 year ago • 3 comments

We should add an API in TextInput (and forward it in LineEdit and TextEdit) to get or set the selection positions

Discussed in https://github.com/slint-ui/slint/discussions/3899

ogoffart avatar Nov 17 '23 11:11 ogoffart

What if we added a get-selected-text() function? That would be straightforward to implement and there’d be no expectation about re-evaluation of the selection changes z

tronical avatar Jan 06 '24 18:01 tronical

if it have this:

VerticalLayout {
  foo := LineEdit {}
  Text { text: foo.get-selected-text(); }
} 

I'd expect the text to change when the selection is changed. (this is trivial to implement) API-wise, i'd probably name it just selected-text and i wonder if it shouldn't be a read-only property.

ogoffart avatar Jan 07 '24 11:01 ogoffart

The setter part was implemented in #4164, but there's no getter yet.

tronical avatar Feb 06 '24 13:02 tronical