Skip to content

feat: add menu-macos and sf-symbols modules#162

Merged
kdroidFilter merged 6 commits intomainfrom
feat/menu-macos-module
Mar 28, 2026
Merged

feat: add menu-macos and sf-symbols modules#162
kdroidFilter merged 6 commits intomainfrom
feat/menu-macos-module

Conversation

@kdroidFilter
Copy link
Copy Markdown
Owner

Summary

  • menu-macos: Complete NSMenu mapping via JNI with a declarative Compose API (NativeMenuBar) for building fully native, reactive macOS application menu bars — supports SF Symbols, keyboard shortcuts, badges, submenus, checkboxes, radio buttons, section headers, alternate items, tooltips, subtitles, indentation, and delegates
  • sf-symbols: 6 195 type-safe Apple SF Symbols constants across 21 categories (SFSymbolArrows, SFSymbolMedia, SFSymbolObjectsAndTools, etc.), usable directly as NsMenuItemImage.SystemSymbol(SFSymbolMedia.PLAY)
  • Plugin fix: CFBundleName now uses appName (fallback packageName) — previously always used packageName. Also auto-injects -Dapple.awt.application.name in the run task on macOS
  • Auto-registration: submenus titled "Services", "Window", or "Help" are automatically registered with macOS via setServicesMenu: / setWindowsMenu: / setHelpMenu:

API

NativeMenuBar {
    Menu("MyApp") {
        Item("About", icon = NsMenuItemImage.SystemSymbol(SFSymbolStatus.INFO_CIRCLE)) { }
        Separator()
        Item("Quit", shortcut = NativeKeyShortcut("q")) { exitProcess(0) }
    }
    Menu("File") {
        Item("New", shortcut = NativeKeyShortcut("n")) { }
        CheckboxItem("Show Toolbar", checked = showToolbar, onCheckedChange = { showToolbar = it })
    }
    Menu("Badges") {
        Item("Inbox", badge = NsMenuItemBadge.Count(42)) { }
    }
}

Test plan

  • ./gradlew :menu-macos:jar — module compiles and packages
  • ./gradlew :sf-symbols:jar — 6195 constants compile
  • ./gradlew :example:run — Menu tab: Install menu bar, verify all menus appear
  • Verify reactive recomposition: type in the title field, move sliders, toggle checkboxes — menu bar updates in real time
  • Verify action callbacks: click menu items, check event log
  • Verify Services menu is populated by macOS
  • Verify menu bar is restored when leaving the Menu tab
  • ./gradlew :example:packageDistributionForCurrentOS — verify CFBundleName uses appName

New modules:
- menu-macos: complete NSMenu/NSMenuItem/NSMenuItemBadge mapping via JNI
  with a declarative Compose API (NativeMenuBar) for building reactive
  native macOS application menu bars
- sf-symbols: 6195 type-safe Apple SF Symbols constants across 21 categories

Plugin fixes:
- Use appName (fallback packageName) for CFBundleName in Info.plist
- Inject -Dapple.awt.application.name in the run task on macOS
- Auto-register Services/Window/Help menus with macOS

Example app demonstrates live menu bar recomposition driven by Compose state.
@kdroidFilter kdroidFilter force-pushed the feat/menu-macos-module branch from 8a33ca1 to e8e4338 Compare March 28, 2026 17:56
@kdroidFilter kdroidFilter merged commit 3d2912d into main Mar 28, 2026
22 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.

1 participant