Skip to content

feat: add keyboard shortcut hints to tray menu items#389

Merged
kdroidFilter merged 5 commits intomasterfrom
feat/keyboard-shortcut-hints
Apr 14, 2026
Merged

feat: add keyboard shortcut hints to tray menu items#389
kdroidFilter merged 5 commits intomasterfrom
feat/keyboard-shortcut-hints

Conversation

@kdroidFilter
Copy link
Copy Markdown
Owner

@kdroidFilter kdroidFilter commented Apr 13, 2026

Summary

  • Adds display-only keyboard shortcut hints for tray menu items (closes Feature Request: Menu item hint for shortcut #174)
  • On macOS, shortcuts render as native key equivalent glyphs (⌘, ⇧, ⌃, ⌥) via NSMenuItem.keyEquivalent / keyEquivalentModifierMask
  • On Windows and Linux, the shortcut parameter is accepted but currently a no-op
  • New KeyShortcut data class with Key enum covering letters, numbers, function keys, and special keys
  • TrayMenuBuilder.Item() and CheckableItem() gain an optional shortcut: KeyShortcut? parameter

API usage

Item("Save", shortcut = KeyShortcut(Key.S, meta = true)) { ... }
Item("New Window", shortcut = KeyShortcut(Key.N, meta = true, shift = true)) { ... }

Test plan

  • Kotlin JVM compilation passes
  • macOS native dylib rebuilt with updated struct layout (stride 40 → 56)
  • DynamicIconsDemo runs with shortcut hints on macOS
  • Verify shortcut glyphs render correctly in tray menu on macOS
  • Verify Windows build is not broken by reserved struct fields
  • Verify Linux build is not broken

Add display-only keyboard shortcut hints on macOS via NSMenuItem
key equivalents. Windows and Linux accept the parameter as noop.

- New KeyShortcut data class with Key enum and modifier flags
- TrayMenuBuilder.Item/CheckableItem gain shortcut parameter
- macOS: extends tray_menu_item struct with key_equivalent fields,
  sets keyEquivalent and keyEquivalentModifierMask on NSMenuItem
- Demo: add shortcut hints to DynamicIconsDemo menu items
Add native support for displaying keyboard shortcuts in Linux tray menus
via the DBusMenu `shortcut` property (aas type). Shortcuts serialize as
DBusMenu-compliant modifier+key arrays and render natively on KDE Plasma.
GNOME's AppIndicator extension does not render this property visually.

- Extend menu_item struct with shortcut fields (key + modifier flags)
- Serialize shortcut property in GetLayout and GetGroupProperties responses
- Add sni_tray_item_set_shortcut() C API and JNI bridge
- Wire shortcuts from Kotlin builder through manager to native code
- Add linuxKeyName to Key enum (XKB naming convention)

Verified on D-Bus: shortcuts correctly exposed as aas arrays.
@kdroidFilter kdroidFilter force-pushed the feat/keyboard-shortcut-hints branch from 9795322 to 6c921dc Compare April 14, 2026 06:13
@kdroidFilter kdroidFilter merged commit 6e2a19a into master Apr 14, 2026
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Feature Request: Menu item hint for shortcut

1 participant