Skip to content

Dynamically change menu items #608

Closed

Description

@ConnorKrammer

I was taking a look at the default app. There's a menu item that causes the app to enter fullscreen, but once in fullscreen the menu item doesn't change from "Enter Fullscreen" to "Exit Fullscreen". This means that once you enter fullscreen though the menu, you cannot exit it.

It seems to me that there should be some way of dynamically changing a menu item's label inside of its own callback. I couldn't find a way to do this without removing the entire menu, creating a new one, then adding it back, but that felt rather heavy handed. Another way to do this would be by removing the single menu item and adding a different one in its place (essentially swapping it out), but there doesn't seem to be any more functionality allowing this than there is for merely changing a label. (A request for the addition of Menu.remove() can be found here.)

I would be willing to contribute to this if given some pointers. It should be noted that I haven't worked with CoffeeScript except in passing, but I can most likely figure it out.

Activity

  1. soh1988 commented on Aug 26, 2014

    @soh1988
    Contributor

    You can create a toggle Fullscreen

    {
    label: 'Toogle Fullscreen',
    accelerator: 'CommandOrControl+F',
    click: function() { mainWindow.setFullScreen( !mainWindow.isFullScreen() ); }
    }

  2. ConnorKrammer commented on Aug 28, 2014

    @ConnorKrammer
    Author

    I figured out how to do that, but from a UX perspective having a more explicit label is the better option.

  3. ConnorKrammer commented on Sep 1, 2014

    @ConnorKrammer
    Author

    @zcbenz any thoughts?

  4. zcbenz commented on Sep 1, 2014

    @zcbenz
    Contributor

    The menu implementation in atom-shell used Chromium's menu library, which provided very limited support for dynamic menus and didn't support removing or adding menu items after the menu was created, so there is no simple way to fix this. But after I figured out a way to implement #528, this would become possible.

    I'm closing this since this is a duplicate of #528.

  5. ConnorKrammer commented on Sep 3, 2014

    @ConnorKrammer
    Author

    Thanks.

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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions