Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. macOS keyboard shortcut handling: Qt problem? Or app problem?
QtWS25 Last Chance

macOS keyboard shortcut handling: Qt problem? Or app problem?

Scheduled Pinned Locked Moved Unsolved General and Desktop
macos
2 Posts 2 Posters 298 Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • I Offline
    I Offline
    ipmcc
    wrote on 16 Jun 2024, 17:59 last edited by
    #1

    I've read a bunch of stuff here about how the MVC approach of macOS Cocoa is somewhat at odds with Qt's architecture. I've noticed some strange behavior in a Qt app (OpenSCAD) on Mac, and I'm curious if this is a problem with Qt or with the app. Here's what I saw:

    macOS has a feature where, even if the app you're using doesn't support custom key bindings, if something is in a menu, regardless of its preset keyboard shortcut, you can create alternate mappings, per application. It's wildly useful for crusty old farts like me who have 35 years of muscle memory to contend with.

    This functionality can be found in System Preferences > Keyboard > Shortcuts > App Shortcuts. Once there, you can add shortcuts to (most) apps. For instance, I've been using other IDEs for years where the indent command is Cmd-Shift-Right, and dedent is Cmd-Shift-Left, this app uses different bindings for indent & dedent.

    When I set up these overrides, I can even see the key combo change in the menu, and the menu gets activated when I press them, but the app doesn't indent/dedent, although weirdly, the initial key combos still do. This makes me suspect that keyboard commands are not using the standard macOS responder chain correctly, but are rather trying to manage keyboard input separately.

    To Reproduce (in this case in OpenSCAD)

    Steps to reproduce the behavior:

    1. Note the before state of the menu:
      Before state
    2. Create a shortcut for Indent as described above in the system-native keyboard shortcuts.
    3. Note the after state of the menu:
      After state
    4. Enter 1 line of code cube(10); for instance
    5. Try to indent and dedent that line of code, using the new key combos.
    6. Observe that the Edit menu flashed (meaning that the shortcut has sent that message up the responder chain through the macOS menu subsystem.)
    7. Observe that the indents and dedents don't happen in the editor.

    Expected behavior:
    I expect the new key combos to actually cause the desired indent and dedent operations in the editor, not just flash the menu.

    Code reproducing the issue
    One line like:

    cube(10);
    

    will allow you to repro this.


    So that's the bullet. Is this a feature of macOS that Qt simply doesn't support? Or has OpenSCAD simply done something wrong?

    Thanks,
    Ian

    M 1 Reply Last reply 16 Jun 2024, 19:51
    0
    • I ipmcc
      16 Jun 2024, 17:59

      I've read a bunch of stuff here about how the MVC approach of macOS Cocoa is somewhat at odds with Qt's architecture. I've noticed some strange behavior in a Qt app (OpenSCAD) on Mac, and I'm curious if this is a problem with Qt or with the app. Here's what I saw:

      macOS has a feature where, even if the app you're using doesn't support custom key bindings, if something is in a menu, regardless of its preset keyboard shortcut, you can create alternate mappings, per application. It's wildly useful for crusty old farts like me who have 35 years of muscle memory to contend with.

      This functionality can be found in System Preferences > Keyboard > Shortcuts > App Shortcuts. Once there, you can add shortcuts to (most) apps. For instance, I've been using other IDEs for years where the indent command is Cmd-Shift-Right, and dedent is Cmd-Shift-Left, this app uses different bindings for indent & dedent.

      When I set up these overrides, I can even see the key combo change in the menu, and the menu gets activated when I press them, but the app doesn't indent/dedent, although weirdly, the initial key combos still do. This makes me suspect that keyboard commands are not using the standard macOS responder chain correctly, but are rather trying to manage keyboard input separately.

      To Reproduce (in this case in OpenSCAD)

      Steps to reproduce the behavior:

      1. Note the before state of the menu:
        Before state
      2. Create a shortcut for Indent as described above in the system-native keyboard shortcuts.
      3. Note the after state of the menu:
        After state
      4. Enter 1 line of code cube(10); for instance
      5. Try to indent and dedent that line of code, using the new key combos.
      6. Observe that the Edit menu flashed (meaning that the shortcut has sent that message up the responder chain through the macOS menu subsystem.)
      7. Observe that the indents and dedents don't happen in the editor.

      Expected behavior:
      I expect the new key combos to actually cause the desired indent and dedent operations in the editor, not just flash the menu.

      Code reproducing the issue
      One line like:

      cube(10);
      

      will allow you to repro this.


      So that's the bullet. Is this a feature of macOS that Qt simply doesn't support? Or has OpenSCAD simply done something wrong?

      Thanks,
      Ian

      M Offline
      M Offline
      mpergand
      wrote on 16 Jun 2024, 19:51 last edited by
      #2

      @ipmcc
      Works for me with ⇧⌘I (shortcut not defined in my opensacd app version)
      ⇧⌘< seems to conflict with ⇧<

      About the responder chain, i'm talking about this HERE

      alt text

      As you can see in this screen shot of QtCReator, The main menu and the context menu are not synchronized (obviously there's nothing to copy), that what I 'm trying to implement in my link above.

      1 Reply Last reply
      0

      2/2

      16 Jun 2024, 19:51

      • Login

      • Login or register to search.
      2 out of 2
      • First post
        2/2
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • Users
      • Groups
      • Search
      • Get Qt Extensions
      • Unsolved