Skip to content

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

Merged
hecrj merged 3 commits into
iced-rs:masterfrom
bradysimon:macos-command-input-behavior
May 31, 2024
Merged

Add Command + ArrowLeft/Right input behavior for macOS#2315
hecrj merged 3 commits into
iced-rs:masterfrom
bradysimon:macos-command-input-behavior

Conversation

@bradysimon

@bradysimon bradysimon commented Mar 8, 2024

Copy link
Copy Markdown

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
Copy Markdown

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

@bradysimon

Copy link
Copy Markdown
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?

Comment thread widget/src/text_editor.rs Outdated
@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

@hecrj hecrj left a comment

Copy link
Copy Markdown
Member

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
@bradysimon bradysimon 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.

3 participants