Bläddra i källkod

app: use logo key on macos instead of ctrl/alt for the shortcuts

darkfi 1 år sedan
förälder
incheckning
d9a819b72f
3 ändrade filer med 17 tillägg och 6 borttagningar
  1. 3 1
      bin/app/src/app/schema/chat.rs
  2. 3 0
      bin/app/src/app/schema/menu.rs
  3. 11 5
      bin/app/src/ui/chatedit.rs

+ 3 - 1
bin/app/src/app/schema/chat.rs

@@ -316,7 +316,9 @@ pub async fn make(
     let node = create_shortcut("back_shortcut");
     #[cfg(target_os = "android")]
     node.set_property_str(atom, Role::App, "key", "back").unwrap();
-    #[cfg(not(target_os = "android"))]
+    #[cfg(target_os = "macos")]
+    node.set_property_str(atom, Role::App, "key", "logo+left").unwrap();
+    #[cfg(all(not(target_os = "android"), not(target_os = "macos")))]
     node.set_property_str(atom, Role::App, "key", "alt+left").unwrap();
     // Not sure what was eating my keys. This is a workaround.
     node.set_property_u32(atom, Role::App, "priority", 10).unwrap();

+ 3 - 0
bin/app/src/app/schema/menu.rs

@@ -306,7 +306,10 @@ pub async fn make(app: &App, window: SceneNodePtr) {
         // Create shortcut
         let channel_id = i + 1;
         let node = create_shortcut(&format!("channel_shortcut_{channel_id}"));
+        #[cfg(not(target_os = "macos"))]
         let key = format!("alt+{channel_id}");
+        #[cfg(target_os = "macos")]
+        let key = format!("logo+{channel_id}");
         node.set_property_str(atom, Role::App, "key", key).unwrap();
         node.set_property_u32(atom, Role::App, "priority", 1).unwrap();
 

+ 11 - 5
bin/app/src/ui/chatedit.rs

@@ -66,8 +66,8 @@ use super::{
 // Avoid updating too much makes scrolling smoother.
 const VERT_SCROLL_UPDATE_INC: f32 = 1.;
 
-macro_rules! d { ($($arg:tt)*) => { debug!(target: "ui::chatview", $($arg)*); } }
-macro_rules! t { ($($arg:tt)*) => { trace!(target: "ui::chatview", $($arg)*); } }
+macro_rules! d { ($($arg:tt)*) => { debug!(target: "ui::chatedit", $($arg)*); } }
+macro_rules! t { ($($arg:tt)*) => { trace!(target: "ui::chatedit", $($arg)*); } }
 
 fn is_all_whitespace(glyphs: &[Glyph]) -> bool {
     for glyph in glyphs {
@@ -1131,9 +1131,15 @@ impl ChatEdit {
     ) -> bool {
         t!("handle_shortcut({:?}, {:?})", key, mods);
 
+        #[cfg(not(target_os = "macos"))]
+        let modkey_pressed = mods.ctrl;
+
+        #[cfg(target_os = "macos")]
+        let modkey_pressed = mods.logo;
+
         match key {
             'a' => {
-                if mods.ctrl {
+                if modkey_pressed {
                     {
                         let mut text_wrap = self.text_wrap.lock();
                         let rendered = text_wrap.get_render();
@@ -1157,7 +1163,7 @@ impl ChatEdit {
                 }
             }
             'v' => {
-                if mods.ctrl {
+                if modkey_pressed {
                     let mut clip = Clipboard::new();
                     if let Some(text) = clip.get() {
                         self.insert_text(&text, atom).await;
@@ -1997,7 +2003,7 @@ impl UIObject for ChatEdit {
 
         let atom = &mut PropertyAtomicGuard::new();
 
-        if mods.ctrl || mods.alt {
+        if mods.ctrl || mods.alt || mods.logo {
             if repeat {
                 return false
             }