Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make TextInput widget hold horizontal scrolling position #2048

Closed
wants to merge 2 commits into from

Conversation

olanti-p
Copy link

This PR adds stateful horizontal scrolling offset for TextInput widget state.

Fixes #1285

The horizontal scrolling value is saved in Focus property of TextInput's State, so it's reset as soon as the widget loses focus.

It is updated on each draw call and is clamped to ensure that:

  1. the cursor always stays visible;
  2. there is no empty space to the right of the text, unless there is not enough text to fill entire width;
  3. there is a bit of space between the cursor in its rightmost position and the clip boundary of the text (original behavior).

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.

@hecrj hecrj added feature New feature or request text widget addition labels Sep 13, 2023
@olanti-p olanti-p marked this pull request as draft October 17, 2023 02:59
@olanti-p olanti-p closed this Jan 23, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

TextInput cursor locks to right side of widget when start of text is not on screen
2 participants