iced
iced copied to clipboard
TextInput cursor locks to right side of widget when start of text is not on screen
Is there an existing issue for this?
- [X] I have searched the existing issues.
Is this issue related to iced?
- [X] My hardware is compatible and my graphics drivers are up-to-date.
What happened?
When there's too much text to fit on screen at once, after scrolling so that the start of the text is no longer visible, the cursor stays stuck to the right side. This makes it harder to read/edit (you can't scroll to a particular word and edit the middle while the whole word is visible), and it leads to some odd behavior when clicking/dragging (dragging left will very quickly scroll all the way back until the start is visible).
This happens both with master (a53fa91e0ddf374bbeb66d5e831b79127ed47a9d) and with 0.2.0.
https://user-images.githubusercontent.com/4934192/158257293-61a6abcd-cfd5-4de7-9384-72484be48c22.mp4
What is the expected behavior?
- The cursor can freely move in the visible range without scrolling/changing the visible text.
- The visible range only moves when the cursor hits the left or right edges.
https://user-images.githubusercontent.com/4934192/158257618-edef78c6-cc9a-4ec6-a1ca-ed9800476343.mp4
Version
master
Operative System
Windows
Do you have any log output?
No response
Yes! This is a missing feature. There is a TODO
in the text_input
module that mentions it:
https://github.com/iced-rs/iced/blob/a53fa91e0ddf374bbeb66d5e831b79127ed47a9d/native/src/widget/text_input.rs#L810
The main challenge is making the horizontal offset "fault-tolerant" (like the Cursor
position), given that the value of the TextInput
can completely change between view
calls and the State
has no way to know about it.