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

textbox has weird behaviour with arrow keys when cursor in whitespace at EOL #1430

Closed
cmyr opened this issue Nov 25, 2020 · 2 comments
Closed
Labels
bug does not behave the way it is supposed to text widget concerns a particular widget

Comments

@cmyr
Copy link
Member

cmyr commented Nov 25, 2020

2020-11-25 17 04 21

arrow keys make the cursor jump around in weird ways when it's in whitespace at the end of a line, and the line has caused the textbox to scroll. There's some funny logic there around making sure we clamp the cursor to the edge of the textbox as necessary, and that may be part of the problem.

@cmyr cmyr added bug does not behave the way it is supposed to widget concerns a particular widget text labels Nov 25, 2020
@cmyr
Copy link
Member Author

cmyr commented Nov 25, 2020

Okay, this comes from a combination of 8db1676 and the fact that we do not include the trailing whitespace when we calculate the width of the line. Annoyingly there's no good way to do this; there are hacky ways (involving hit-testing at end-of-line and using the returned value as our width) but nothing that feels right. I have a patch that improves the situation, but still feels weird in some circumstances, but it might be worth it for now; or we can revert 8db1676.

(my patch is just doing let overall_text_width = overall_text_width.max(cursor_x) at the top of TextBox::update_hscroll.)

cmyr added a commit that referenced this issue Nov 26, 2020
This fixes the issue with the cursor jumping, but does not fix
the underlying problem, which is related to us not providing a
good API for including the whitespace in text width calculations.

see #1430
cmyr added a commit that referenced this issue Dec 1, 2020
This fixes the issue with the cursor jumping, but does not fix
the underlying problem, which is related to us not providing a
good API for including the whitespace in text width calculations.

see #1430
cmyr added a commit that referenced this issue Dec 1, 2020
This fixes the issue with the cursor jumping, but does not fix
the underlying problem, which is related to us not providing a
good API for including the whitespace in text width calculations.

see #1430
@cmyr
Copy link
Member Author

cmyr commented Mar 18, 2021

As of #1636 this is handled by the input controller (although there is still a remaining issue with calculating whitespace width on mac, that will be fixed with the next piet release)

@cmyr cmyr closed this as completed Mar 18, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug does not behave the way it is supposed to text widget concerns a particular widget
Projects
None yet
Development

No branches or pull requests

1 participant