Skip to content

Commit

Permalink
Fix macOS Option key
Browse files Browse the repository at this point in the history
  • Loading branch information
dzhou121 committed Aug 2, 2022
1 parent 7f4db05 commit 474bb00
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 5 deletions.
6 changes: 3 additions & 3 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

14 changes: 12 additions & 2 deletions lapce-data/src/keypress/mod.rs
Expand Up @@ -318,7 +318,7 @@ impl KeyPressData {
focus: &mut T,
env: &Env,
) -> bool {
println!("Keypress: {key_event:?}");
log::info!("Keypress: {key_event:?}");

// We are removing Shift modifier since the character is already upper case.
let mods = Self::get_key_modifiers(key_event);
Expand Down Expand Up @@ -393,12 +393,22 @@ impl KeyPressData {

self.count = None;

if keypress.mods.is_empty() || keypress.mods == Modifiers::SHIFT {
#[cfg(not(target_os = "macos"))]
if (keypress.mods - Modifiers::SHIFT).is_empty() {
if let druid::KbKey::Character(c) = &key_event.key {
focus.receive_char(ctx, c);
return true;
}
}

#[cfg(target_os = "macos")]
if (keypress.mods - (Modifiers::SHIFT | Modifiers::ALT)).is_empty() {
if let druid::KbKey::Character(c) = &key_event.key {
focus.receive_char(ctx, c);
return true;
}
}

false
}

Expand Down

0 comments on commit 474bb00

Please sign in to comment.