8000 feat: allow MenuItems to work optionally when hidden by codebytere · Pull Request #16853 · electron/electron · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

feat: allow MenuItems to work optionally when hidden #16853

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

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
@codebytere codebytere force-pushed the menu-item-work-disabled branch from 3a5cdac to d69c03f Compare February 8, 2019 22:46
@codebytere codebytere requested a review from brenca February 8, 2019 22:47
@codebytere codebytere force-pushed the menu-item-work-disabled branch from 13eec15 to 598fb1f Compare February 9, 2019 02:47
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.

👍

@codebytere codebytere force-pushed the menu-item-work-disabled branch from d212262 to d2770a1 Compare February 27, 2019 08:34
@codebytere codebytere force-pushed the menu-item-work-disabled branch from d2770a1 to cb3daa7 Compare February 27, 2019 09:12
@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.

5 participants
0