feat: add trigger option for tray event binding#6
Merged
Conversation
Introduces `Options.trigger` ('click' | 'right-click' | 'none') as the
single source of truth for which tray event toggles the menubar window.
Deprecates `showOnRightClick`, which is kept as a fallback when
`trigger` is unset.
`trigger: 'none'` skips the tray click bindings entirely, enabling the
"one tray icon, multiple anchored windows" pattern: instantiate a
secondary Menubar to reuse the tray-anchored positioning while driving
visibility manually via `showWindow()` (e.g. from a context menu).
The motivating use case was raised in upstream max-mapper#485
by @haydendonald as a `disableClick` boolean. An enum subsumes both that
flag and `showOnRightClick`, avoids a double-negative API, and leaves
room for future trigger types.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Introduces
Options.trigger— a'click' | 'right-click' | 'none'enum that controls which tray event toggles the menubar window. Deprecates theshowOnRightClickboolean, which is kept as a fallback for one minor.trigger: 'none'skips all tray click bindings, enabling the one tray icon, multiple anchored windows pattern: a secondaryMenubarinstance reuses tray-anchored positioning while the caller drives visibility viashowWindow()(typically from a context-menu entry).Why an enum, not a
disableClickbooleanThe motivating use case was raised upstream as max-mapper/menubar#485 by @haydendonald, who proposed a
disableClick: booleanflag. We're going further:disableClickis a negative-named boolean, anddisableClick: falsereads as a double-negative.showOnRightClick—{ showOnRightClick: true, disableClick: true }quietly disables right-click too, since the wrappingifcovers both registration paths. The name lies.disableDoubleClickordisableRightClick, so the API can't grow cleanly.A single
triggerenum subsumes both flags, is self-documenting, leaves room for future values (e.g.'double-click'), and gives a clean migration path offshowOnRightClick.Migration
trigger: 'click')showOnRightClick: truetrigger: 'right-click'trigger: 'none'showOnRightClickstill works and is honored whentriggeris unset; it's marked@deprecatedand slated for removal in the next major.Test plan
bun run test— 18 tests pass, including 5 new cases fortrigger:click+double-clicktrigger: 'right-click'bindsright-click+double-click, notclicktrigger: 'none'binds nothingtriggerfalls back toshowOnRightClicktriggerwins overshowOnRightClickwhen both are setbun run typecheck— cleanbun run lint:check— clean (one pre-existing warning, unrelated)bun run build— ESM/CJS bundles produced