-
Notifications
You must be signed in to change notification settings - Fork 2.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support dynamic menu items in electron #446
Comments
I think electron/electron#528 (comment) could be a viable workaround until they support updates in the rendering process. |
I have noticed that too, but when do you fire the |
you are right. Is there a callback on menu show? |
I was looking for something like that but did not find anything useful. |
@kittaakos I noticed that vscode has the option of having custom menus (much like our browser), would this be a viable option to update our menus to use our browser menus instead so we have more control and customizability over them ? |
This should be possible to do with the current electron version we use.
/**
* Emitted when a popup is closed either manually or with menu.closePopup().
*/
on(event: 'menu-will-close', listener: (event: Event) => void): this;
once(event: 'menu-will-close', listener: (event: Event) => void): this;
addListener(event: 'menu-will-close', listener: (event: Event) => void): this;
removeListener(event: 'menu-will-close', listener: (event: Event) => void): this;
/**
* Emitted when menu.popup() is called.
*/
on(event: 'menu-will-show', listener: (event: Event) => void): this;
once(event: 'menu-will-show', listener: (event: Event) => void): this;
addListener(event: 'menu-will-show', listener: (event: Event) => void): this;
removeListener(event: 'menu-will-show', listener: (event: Event) => void): this; I propose adding this to our road-map, so finally, we can have the same application menu behavior in the browser and electron. |
From now on, we update the main menu and its items when - the `currentWidget` changes, and - the curren selection is set on the selection service. Closes #446. Signed-off-by: Akos Kitta <[email protected]>
My workaround was to get mouse cursor position when the user clicks on the menu, and then show it at the coordinates after recreating it with
... then rebuild it with
It should work with Tray too. |
There is an even for when menus in the menu bar are opened (
That said, the documentation says we can update the |
Unfortunately, changing the aforementioned flags in |
We already have some change notification in place when updating toolbar items upon change of context keys in the case of the VS Code command |
Hello, would you consider adding support for dynamic main menu and context menu by creating the menu items on the fly? We have use cases where the number of menu items can change, including visibility, enablement, and label based on the state of our debugger. My current workaround is to define a large number of placeholder menu items, and then set the visibility depending on the debugger state. In older Theia, there is a way to change the label. But the menu item label property is made private in newer Theia. |
@pchuong that is already possible if you don't use the native electron menus. As for the electron case, I don't think it's possible for the reasons I explained in my comments above. |
@pchuong not really sure what you mean about the label being private? Seems public in |
@kittaakos I don't think we can make "on-demand" menus work for the main menu with what we have in Electron. My approach would be to track handler visibility & enablement and to push updates actively into the Electron main process. What do you think? It would probably be best to introduce change notification into the |
Currently, the menu items are built at application startup and have their static nature. That means,
enabled
,visible
properties are not updated dynamically.Also, handler enablement is calculated when the application starts.
For now on, I enable everything (#210), just like VSCode and move the command > handler lookup into the
click(()
function.See: electron/electron#528
The text was updated successfully, but these errors were encountered: