✨ Add "Keep Open" option for menu items#1336
Open
manuxdev wants to merge 5 commits intokando-menu:mainfrom
Open
✨ Add "Keep Open" option for menu items#1336manuxdev wants to merge 5 commits intokando-menu:mainfrom
manuxdev wants to merge 5 commits intokando-menu:mainfrom
Conversation
webpack 5 no longer polyfills Node.js built-ins like 'events' by default. Added resolve.fallback for the 'events' module so the renderer bundle can use EventEmitter in browser context. Also added fs-extra and @types/fs-extra as explicit devDependencies since the package was already used in src/main/ but only available as a transitive dependency, which causes issues with strict package managers like pnpm.
Adds a new 'keepOpen' boolean property to menu items that prevents the menu from closing after the item's action is executed. This allows users to trigger the same action repeatedly (e.g. volume up/down, undo/redo, media controls) without having to reopen the menu each time. Changes: - Added 'keepOpen' field to MENU_ITEM_SCHEMA_V1 - Added 'resetLeafSelection()' public method to Menu class to restore the menu to its interactive state without closing it - Saved and restored root position on reset to prevent visual shift - Skipped hideWindow() in the main process for keepOpen items - Added 'Keep menu open' checkbox in the item properties panel (visible for all non-root, non-submenu item types) - Added English translations for the new option
On macOS, CGEventPost sends simulated keys to the frontmost app. Since the Kando window is active while the menu is open, hotkey/macro actions executed via keepOpen would be consumed by Kando itself instead of the target application. Fix: before executing a keepOpen action on macOS, activate the previous app (via `open -b <bundleId>`) so simulated keys reach the right target. After execution, refocus the Kando window to keep the menu interactive.
- On macOS, activate the previous app before executing keepOpen hotkey/macro actions so simulated keys reach the target app instead of Kando - Add try/finally in simulateKeys() to ensure shortcut inhibition is always released even if key simulation fails (e.g. missing accessibility permissions)
9028ae6 to
c6ae8e4
Compare
Contributor
|
Hey there! Thanks a ton for looking into this. It works quite well! Yet I'm not sure if this is the best solution to this problem. I think it would be better if the user could somehow decide whether the menu should stay open after a selection. With this new option turned on, it is pretty awkward if you want to execute the action only once. I think it's a valid use case that a user may want to keep the menu open sometimes but not every time. Have you looked into #1190? I think that maybe using middle-mouse click instead of this option could be a good approach. What do you think? |
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.
This PR adds a
keepOpenboolean property to menu items that allows themenu to stay open after an item is selected. This is useful for actions
that users want to execute repeatedly without having to reopen the menu
each time (e.g. volume control, media playback, etc.).
Changes
keepOpen: booleanfield toMENU_ITEM_SCHEMA_V1keepOpenitem is selected, the menu resetsto its previous interactive state instead of closing
hideWindow()and delayed execution forkeepOpenitems, executing the action immediately insteadproperties panel (shown for all non-submenu item types)
keep-openandkeep-open-infokeys tolocales/en/translation.jsoneventspolyfill for webpack 5 rendererbundle, and added
fs-extraas explicit dev dependency (required forpnpm strict isolation)
How it works
selectevent withkeepOpen=trueresetLeafSelection()instead of hiding the menu,restoring the menu to its pre-selection state
hideWindow()Testing