Skip to content
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

feat: allow MenuItems to work optionally when hidden #16853

Merged
merged 2 commits into from Feb 28, 2019

Conversation

codebytere
Copy link
Member

@codebytere codebytere commented Feb 8, 2019

Description of Change

Resolves #16747.

This PR enables MenuItems on macOS to work optionally when visible: false. using a new MenuItem option acceleratorWorksWhenHidden. The default of this new options is true, to match behavior on Windows and Linux, but since native macOS development allows for this to be turned off, this option allows that to be done.

Example:

  const menu = Menu.buildFromTemplate([
    {
      label: 'View',
      submenu: [
        { role: 'zoomin' },
        { 
          role: 'zoomout', 
          visible: false,
          acceleratorWorksWhenHidden: true
        },
      ],
    }
  ])

cc @MarshallOfSound @zcbenz

Checklist

Release Notes

Notes: Added an option to enable MenuItems on macOS to work optionally when visible: false.

@codebytere codebytere requested review from a team February 8, 2019 22:34
@@ -302,8 +307,7 @@ - (void)addItemToMenu:(NSMenu*)menu
}

// Called before the menu is to be displayed to update the state (enabled,
// radio, etc) of each item in the menu. Also will update the title if
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

comment removed as it's a remnant of dead code previously removed in #14939

@codebytere codebytere changed the title [wip] feat: allow MenuItems to work optionally when hidden feat: allow MenuItems to work optionally when hidden Feb 8, 2019
@codebytere codebytere added semver/minor backwards-compatible functionality target/5-0-x labels Feb 8, 2019
atom/browser/api/atom_api_menu.cc Outdated Show resolved Hide resolved
docs/api/menu-item.md Outdated Show resolved Hide resolved
Copy link
Contributor

@brenca brenca left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

docs/api/menu-item.md Show resolved Hide resolved
@MarshallOfSound
Copy link
Member

Looks like you're gonna need one of those lovely Forward Declarations 😢

../../electron/atom/browser/ui/cocoa/atom_menu_controller.mm:296:11: error: instance method '-setAllowsKeyEquivalentWhenHidden:' not found (return type defaults to 'id') [-Werror,-Wobjc-method-access]
          setAllowsKeyEquivalentWhenHidden:(model->WorksWhenHiddenAt(index))];

@codebytere
Copy link
Member Author

@MarshallOfSound oops yeah i was planning on fixing this yesterday but then gclient died on me; fixing soon :)

@codebytere codebytere merged commit 544d8a4 into master Feb 28, 2019
@release-clerk
Copy link

release-clerk bot commented Feb 28, 2019

Release Notes Persisted

Added an option to enable MenuItems on macOS to work optionally when visible: false.

@trop
Copy link
Contributor

trop bot commented Feb 28, 2019

I have automatically backported this PR to "5-0-x", please check out #17175

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
semver/minor backwards-compatible functionality
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants