drawbot icon indicating copy to clipboard operation
drawbot copied to clipboard

Text selection/deselection via keyboard is unintuitive

Open frankrolf opened this issue 5 years ago • 6 comments

I have left private feedback about this before, but would like to pick this up again.

It is a common macOS paradigm that text can be selected with shift- and arrow keys, plus various optional control keys. cmd shift will select until the beginning of a line. cmd shift will select until the end of a line. alt shift will select word by word to the right etc …

This behavior is implemented in many code editors and OS applications, and also in DrawBot. What’s particular about DrawBot is that any selection of text can only be enlarged, and not easily reduced.

In the following text string, I would like to get rid of the extra spaces before the last tuple:

return (x0, y0), (x1, y1), (x2, y2),                 (x3, y3)

In any other application, I would navigate to the comma after y2), select with alt shift , and decrease the right end of the selection by 1 or more characters by using with shift still down.

This doesn’t work in DrawBot. Instead, the selection at the left edge is increased. Why? I don’t know. Could it be that the code editor assumes the insertion point to still be on the original location?

See some example videos here: TextEdit: https://www.dropbox.com/scl/fi/gkzyxqilk6wavlzehpqyc/TextEdit.mov?rlkey=4oz07lejq50srdvive94kmnux&dl=0 SublimeText: https://www.dropbox.com/scl/fi/bb07aus0i7at0bzytca9h/Sublime.mov?rlkey=0l05fqlocn7uei1y2v61gcqbd&dl=0 DrawBot: https://www.dropbox.com/scl/fi/wwxqf8ixfnwrkba05t8pa/DrawBot.mov?rlkey=kco11wjvhe7g99icuf94rn5ja&dl=0

I stumble over this every time I use the internal DrawBot code editor, I hope I’m not the only one!

frankrolf avatar Aug 12 '19 16:08 frankrolf

In my observation (on 10.10) the reducing of the selection only does not work when the command key is used. For me, shift-arrow and alt-shift-arrow combinations works as expected.

It may have to do with DrawBot's overloading of the command-arrowkey combinations to increment/decrement numbers. Will need to look into the code.

justvanrossum avatar Aug 14 '19 07:08 justvanrossum

For the record, I observe this on 10.14, and 10.15 Beta. Maybe unrelated, but perhaps worth mentioning: The behavior in the RoboFont 3 code editor is the same.

frankrolf avatar Aug 14 '19 20:08 frankrolf

And just so I understand correctly: you observe the wrong behavior also for shift-arrow and alt-shift-arrow, without the command key?

justvanrossum avatar Aug 15 '19 05:08 justvanrossum

That’s correct. step-by-step:

  • insert the cursor after y2),
  • hold alt shift and push
  • _________________( is selected (spaces visualized by underscores here)
  • let go of alt
  • push

expected:

  • selection is decreased on the right side so that only spaces are selected

actually happening:

  • selection is increased on left side, resulting in a selection of ,_________________(

Please also have a look at the 3rd video, which has keystrokes visualized.


BTW: selection with cmd-key works alright!

  • insert the cursor somewhere in the middle of the line
  • hold cmd shift and push
  • everything until the end of the line is selected
  • let go of cmd
  • push
  • selection is decreased on the right side.

frankrolf avatar Aug 15 '19 07:08 frankrolf

Hi there, I wanted to chime in here and say that I'm also having this issue (can reproduce with Frank’s steps). It's odd that the code editor seems to have a memory of how the text was selected (cmd vs. alt) when attempting to deselect.

I'm having a hard time figuring out where in the code this type of text selection happens.

BTW, I don't think this is consequential, but was wondering why this altDown line is repeated sometimes.

ryanbugden avatar Sep 20 '23 17:09 ryanbugden

for moveLeft left arrow it happens here: https://github.com/typemytype/drawbot/blob/b4a758c11e8c8664ff98a0a644a55f043d736ded/drawBot/ui/codeEditor.py#L794

typemytype avatar Sep 20 '23 18:09 typemytype