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

osx uses super+arrows for home/end, built on work in ocornut/imgui#473 #650

Merged
merged 2 commits into from Jul 29, 2016

Conversation

michaelbartnett
Copy link
Contributor

Was really happy to see the OSX shortcuts implemented for text fields.

Last major thing missing for OSX text field conventions was to use Cmd+Left/Right for Home/End and Cmd+Up/Down for Ctrl+Home/End.

Added another bool, ImGuiIO::HomeEndUsesArrowSuperKeys. I don't know how many of these is too many, but trying to use the other var, ShortcutsUseSuperKey, wasn't coming out as clear since it's not just a modifier swap.

Also tested on Linux, didn't notice any regressions in the non-OSX behavior.

@michaelbartnett
Copy link
Contributor Author

michaelbartnett commented Jul 7, 2016

Updating this PR to keep current with master and also to better summarize the changes.

Here's what this does:

  1. Introduces ImGuiIO::HomeEndUsesArrowSuperKey.

    Just like io.ShortcutsUseSuperKey, this new io.HomeEndUsesArrowSuperKey flag defaults to true on OSX via platform defines.

  2. When io.HomeEndUsesArrowSuperKey is true:

    • Super+Left Moves to Line Start
    • Super+Right Moves to Line End
    • Super+Up Moves to Text Start
    • Super+Down Moves to Text End
    • (Shift modifier also changes selection as expected)
  3. When io.ShortcutsUseSuperKey is true:

    • Alt+Backspace deletes backward by word
    • Cmd+Backspace deletes to Line Start

This makes text cursor movement mostly idiomatic for OSX. Although text controls on OSX don’t usually map Home/End to move-to-line-start/move-to-line-end, I didn’t see much value in further muddying up the code just to prevent that.

@ocornut
Copy link
Owner

ocornut commented Jul 12, 2016

Thanks Michael, and sorry I haven't had time to look at it and merge. Will try soon.
I actually managed to borrow a Mac so it'll be helpful to test bigger Mac related changes (this specific PR is simple enough tho).

@michaelbartnett
Copy link
Contributor Author

Hi Omar, thanks for your reply, don't sweat it! Happy to keep this merging cleanly until you have time to deal with Mac changes.

@ocornut ocornut merged commit 921fc50 into ocornut:master Jul 29, 2016
ocornut added a commit that referenced this pull request Jul 29, 2016
ocornut added a commit that referenced this pull request Jul 29, 2016
@ocornut
Copy link
Owner

ocornut commented Jul 29, 2016

Merged with a bunch of minor/shallow cleanups.
I have decided to remove the 5 individual behaviors boolean, they made the code just more confusing and were unlikely to be ever set separately. Individual comments stayed.

Instructions in ShowUserGuide() and optionally one occurrence of calling ShowHelpMarker() in the demo code should also be updated to reflect OSX controls.

ocornut added a commit that referenced this pull request Nov 12, 2017
… Renamed io.OSXBehaviors to io.OptMacOSXBehaviors. Should affect users as the compile-time default is usually enough. (#473, #650)
ocornut added a commit that referenced this pull request Aug 1, 2018
… io.OptCursorBlink to io.ConfigCursorBlink, io.OptMacOSXBehaviors to ConfigMacOSXBehaviors for consistency. (#1427, #1495, #822, #473, #650)

Demo: Exposed flags in Demo.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants