Make TextInput widget hold horizontal scrolling position #2048
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR adds stateful horizontal scrolling offset for TextInput widget state.
Fixes #1285
The horizontal scrolling value is saved in
Focus
property of TextInput'sState
, so it's reset as soon as the widget loses focus.It is updated on each
draw
call and is clamped to ensure that:This way, even if the underlying value changes or the cursor is moved through any means, the widget will scroll to accommodate the change.
Mouse selection now also works as expected: the view won't move while the user selects text in the middle, and will scroll left or right if the mouse cursor is dragged to the left/right edge or beyond. Clicking on an unfocused widget now always puts the text cursor under the mouse cursor, regardless of where the (invisible while unfocused) text cursor was before that.