diff options
author | 2024-05-31 16:32:12 +0200 | |
---|---|---|
committer | 2024-05-31 16:32:12 +0200 | |
commit | 06ff17fcf87495663a295d1548df1c2ac03dafbd (patch) | |
tree | 5dbfe97e50662cdaf396427d7793c4f03fc159c6 /widget/src/text_editor.rs | |
parent | 12f4b875cfb0eeb0bac5416921c6cec40edd420c (diff) | |
parent | 3312dc808012e2c049fb2f178d51bfe0b4e30399 (diff) | |
download | iced-06ff17fcf87495663a295d1548df1c2ac03dafbd.tar.gz iced-06ff17fcf87495663a295d1548df1c2ac03dafbd.tar.bz2 iced-06ff17fcf87495663a295d1548df1c2ac03dafbd.zip |
Merge pull request #2315 from Brady-Simon/macos-command-input-behavior
Add Command + ArrowLeft/Right input behavior for macOS
Diffstat (limited to 'widget/src/text_editor.rs')
-rw-r--r-- | widget/src/text_editor.rs | 26 |
1 files changed, 11 insertions, 15 deletions
diff --git a/widget/src/text_editor.rs b/widget/src/text_editor.rs index 7c0b98ea..41b058af 100644 --- a/widget/src/text_editor.rs +++ b/widget/src/text_editor.rs @@ -768,9 +768,17 @@ impl Update { if let keyboard::Key::Named(named_key) = key.as_ref() { if let Some(motion) = motion(named_key) { - let motion = if platform::is_jump_modifier_pressed( - modifiers, - ) { + let motion = if modifiers.macos_command() { + match motion { + Motion::Left => Motion::Home, + Motion::Right => Motion::End, + _ => motion, + } + } else { + motion + }; + + let motion = if modifiers.jump() { motion.widen() } else { motion @@ -807,18 +815,6 @@ fn motion(key: key::Named) -> Option<Motion> { } } -mod platform { - use crate::core::keyboard; - - pub fn is_jump_modifier_pressed(modifiers: keyboard::Modifiers) -> bool { - if cfg!(target_os = "macos") { - modifiers.alt() - } else { - modifiers.control() - } - } -} - /// The possible status of a [`TextEditor`]. #[derive(Debug, Clone, Copy, PartialEq, Eq)] pub enum Status { |