You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: apps/desktop/src-tauri/src/menu/CLAUDE.md
+14Lines changed: 14 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -56,6 +56,16 @@ frontend when Settings or file viewer gains/loses focus. Iterates the `items` Ha
56
56
Uses `objc2::exception::catch` because NSMenu operations can raise ObjC exceptions inside Tauri's
57
57
`did_finish_launching` callback, which aborts on panic.
58
58
59
+
### SF Symbol icons (macOS only)
60
+
61
+
`set_macos_menu_icons()` runs post-construction via objc2 FFI, walking
62
+
`NSApplication.mainMenu()` and calling `NSImage(systemSymbolName:)` + `setImage:` on each
63
+
`NSMenuItem` matched by title. This produces true template images that auto-tint on
64
+
selection highlighting. Also handles nested submenus (Sort by) via
65
+
`apply_sf_symbols_to_nested_submenu`. Context menus do NOT have icons — Tauri doesn't expose the
66
+
raw `NSMenu` pointer for context menus, and rasterized SF Symbol bitmaps via `IconMenuItem` look
67
+
poor (no template auto-tinting).
68
+
59
69
## Platform differences
60
70
61
71
| Aspect | macOS | Linux |
@@ -66,6 +76,7 @@ Uses `objc2::exception::catch` because NSMenu operations can raise ObjC exceptio
66
76
| Mnemonics | Not used |`&` prefixes for GTK keyboard navigation, unique per submenu |
67
77
| Help search | Native NSMenu search field via `setHelpMenu:`| Not available |
68
78
| System cleanup | objc2 strips injected Edit items | Not needed |
79
+
| Menu icons | SF Symbols via objc2 (menu bar) and IconMenuItem (context menus) | Not supported |
69
80
70
81
## Menu structure
71
82
@@ -101,6 +112,9 @@ also Window and Help.
101
112
**Decision**: CheckMenuItems (view modes, show hidden) use separate event paths instead of `"execute-command"`.
102
113
**Why**: CheckMenuItems auto-toggle their checked state on click. If the click also emitted `"execute-command"` and the frontend toggled the setting, the state would double-toggle (menu toggles once, frontend toggles again). Instead, these items emit `"settings-changed"` or `"view-mode-changed"` directly, treating the menu click as the authoritative state change.
103
114
115
+
**Decision**: SF Symbol icons only on the menu bar, not on context menus.
116
+
**Why**: Tauri doesn't support SF Symbols natively. For the menu bar, we walk `NSApplication.mainMenu()` post-construction via objc2 FFI and set SF Symbols directly on `NSMenuItem` objects — this produces true template images that auto-tint correctly. Context menus don't get icons because Tauri doesn't expose the raw `NSMenu` pointer, and the alternative (rasterized bitmaps via `IconMenuItem`) produces visually poor results (no template tinting, wrong size/weight).
117
+
104
118
## Gotchas
105
119
106
120
-**No `Menu::default()`**: Both platforms build from scratch. The old approach inherited system
0 commit comments