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

Add Command + ArrowLeft/Right input behavior for macOS #2315

Merged
merged 3 commits into from
May 31, 2024

Conversation

Brady-Simon
Copy link

@Brady-Simon Brady-Simon commented Mar 8, 2024

This PR adds macOS-specific behavior for the input and text editor for Command + ArrowLeft to behave like Home and Command + ArrowRight to behave like End to match the native behavior. This behavior is particularly useful for users with MacBooks since there aren't Home/End keys on the keyboard.

I added a new platform::is_macos_command_pressed function instead of using modifiers.command() since the latter defaults to CTRL on other platforms and represents a jump instead of moving to the beginning/end of the line.

This PR leaves out other shortcuts like Command + ArrowUp -- which would also move to the cursor to the beginning of the line for single line inputs and the beginning of the document for multi-line inputs -- to limit the scope of changes.

@oldgalileo
Copy link

Could this also be extended to address Option + <Arrow>?

@Brady-Simon
Copy link
Author

Option + <Arrow> is a jump between words instead of moving to the beginning/end of the line like Command, so that should be working already on recent versions of Iced. What behavior are you seeing with option + arrow?

widget/src/text_editor.rs Outdated Show resolved Hide resolved
@Brady-Simon Brady-Simon force-pushed the macos-command-input-behavior branch from e851526 to 5602459 Compare May 3, 2024 19:18
@hecrj hecrj force-pushed the macos-command-input-behavior branch 2 times, most recently from 6f3225d to e249e56 Compare May 31, 2024 14:13
@hecrj hecrj force-pushed the macos-command-input-behavior branch from e249e56 to 8cfa814 Compare May 31, 2024 14:15
@hecrj hecrj added this to the 0.13 milestone May 31, 2024
@hecrj hecrj added bug Something isn't working text widget fix labels May 31, 2024
Copy link
Member

@hecrj hecrj left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

@hecrj hecrj enabled auto-merge May 31, 2024 14:24
@hecrj hecrj merged commit 06ff17f into iced-rs:master May 31, 2024
12 checks passed
@Brady-Simon Brady-Simon deleted the macos-command-input-behavior branch May 31, 2024 14:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working fix text widget
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants