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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants