Skip to content

[WIP] [macOS] Handle keyboard shortcuts using NSMenuItem

Created by: ColinKinloch

This allows keyboard shortcuts to be handled by macOS rather than by godot which correctly handles the keyboard layout "Dvorak - QWERTY ⌘".

Fixes #4386 (closed)

This solution may seem a bit hacky but reading the macOS developer docs, it's the only way I could figure see. As far as I can tell:

  • there is no way to get info on the shortcut remapping done for "Dvorak - QWERTY ⌘" from the macOS API.
  • there is no way to create a keyboard shortcut ("keyEquivalent") without adding it to the menu bar.

This code still has a few issues that need worked out:

  • the shift modifier is incorrectly being added to shortcuts that don't have shift.
  • godot shortcut handling should be disabled so that unremapped keyboard shortcuts don't get triggered.
  • shortcuts cannot yet be changed or removed.

Merge request reports