Skip to content

macOS: primaryAction = null leaves left-click dead - menu only opens on right-click #438

Description

@EugenMayer

Version: dev.nucleusframework:composenativetray:2.1.6
OS: macOS 26
Compose Multiplatform: 1.12.0
JDK: temurin 25

What I'm doing

I want the tray's left-click to toggle my window on Windows and Linux, but on macOS I want left-click to open the native context menu (standard NSStatusItem behavior). Per the docs — "Without it, the menu opens on every click" — I pass primaryAction = null on macOS only:

val primaryAction: (() -> Unit)? =
    if (OperatingSystem.isMacOS()) null
    else { { appState.mainWindowVisible.value = !appState.mainWindowVisible.value } }

Tray(
    icon = painterResource(Res.drawable.app_logo),
    tooltip = "MyApp",
    primaryAction = primaryAction,
) {
    Item(label = "Show window") { /* ... */ }
    Divider()
    Item(label = "Quit") { exitProcess(0) }
}

Expected

On macOS, with primaryAction = null, left-clicking the tray icon opens the context menu.

Actual

On macOS, left-clicking the tray icon does nothing. Right-clicking does open the menu correctly, and the menu items are populated. So the menu itself is fine — only the left-click-to-open path is dead when primaryAction is null.

Windows behaves correctly: left-click toggles the window, right-click opens the menu.
Linux also opens the menu on left click (different issue #439).

Notes

OperatingSystem.isMacOS() is confirmed returning true on the affected machine (verified via logging), so the null branch is definitely in effect. This looks related to the macOS click handling from #420 (performClick for the context menu) — right-click reaches that path but left-click with a null primaryAction does not, so nothing opens.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions