cycfi / elements

Elements C++ GUI library
http://cycfi.github.io/elements/
3.15k stars 235 forks source link

Editable text field doesn't listen to Shift + Home/End #377

Closed joriswave closed 9 months ago

joriswave commented 9 months ago

As an alternative to Ctrl+A, it should be possible to select all text in a text field by doing Home/End, Shift+End/Home. Currently, the Shift doesn't trigger selection to happen.

Additionally/optionally, Ctrl+Left/Right Arrow should jump by "words" (and Shift+Ctrl+Left/Right select by "words" ).

djowel commented 9 months ago

Fixed

djowel commented 9 months ago

Additionally/optionally, Ctrl+Left/Right Arrow should jump by "words" (and Shift+Ctrl+Left/Right select by "words" ).

BTW, probably mac centric, IDK, but moving by words is option/alt+Left/Right and selecting words is shift+option/alt+Left/Right

djowel commented 9 months ago

Additionally/optionally, Ctrl+Left/Right Arrow should jump by "words" (and Shift+Ctrl+Left/Right select by "words" ).

BTW, probably mac centric, IDK, but moving by words is option/alt+Left/Right and selecting words is shift+option/alt+Left/Right

OK, I implemented using the option key for moving cursor across words in the Mac and control key in Windows and Linux. Please test on Windows. It seems the Mac is the only one using the option key for moving cursor across words.

djowel commented 9 months ago

@joriswave BTW, another way to select all is by triple click.

joriswave commented 9 months ago

OK, I implemented using the option key for moving cursor across words in the Mac and control key in Windows and Linux. Please test on Windows. It seems the Mac is the only one using the option key for moving cursor across words.

Works - thank you! 🙏 The only thing now is that usually a "word" doesn't only end with a space character, but also a non-letter character (don't know the exact rule here, or if there even is a standard), such that you can, e.g., skip over the sub folders within a file path or url with Ctrl+Left/Right.

@joriswave BTW, another way to select all is by triple click.

👍

djowel commented 9 months ago

The only thing now is that usually a "word" doesn't only end with a space character, but also a non-letter character (don't know the exact rule here, or if there even is a standard), such that you can, e.g., skip over the sub folders within a file path or url with Ctrl+Left/Right.

There are precise rules for that dictated by the Unicode Line Breaking Algorithm. See the linebreak library that Elements uses: https://github.com/foliojs/linebreak which also deals with word breaks. No, the slash is not a word break.