iced-rs / iced

A cross-platform GUI library for Rust, inspired by Elm
https://iced.rs
MIT License
23.06k stars 1.06k forks source link

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

Closed Brady-Simon closed 1 day ago

Brady-Simon commented 2 months ago

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 commented 1 month ago

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

Brady-Simon commented 1 month ago

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?