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

Add default label and accelerator for menu item roles #6190

Merged
merged 19 commits into from Jun 23, 2016

Conversation

kevinsawicki
Copy link
Contributor

@kevinsawicki kevinsawicki commented Jun 22, 2016

Adds fallback labels and accelerators for all MenuItem roles.

This allows you to use menu item roles like so:

{
      label: 'Edit',
      submenu: [
        {
          role: 'undo'
        },
        {
          role: 'redo'
        },
        {
          type: 'separator'
        },
        {
          role: 'cut'
        },
        {
          role: 'copy'
        },
        {
          role: 'paste'
        }
}

And the accelerators and labels will be automatically provided as so:

screen shot 2016-06-22 at 2 19 30 pm

Close #2812

@kevinsawicki
Copy link
Contributor Author

/cc @sindresorhus 👀

@sindresorhus
Copy link
Contributor

sindresorhus commented Jun 22, 2016

Awesome!

One of the main benefits of doing this would have been automatic localization. Doesn't look like this PR handles that. From the issue:

we can probably copy and use the resources from Chromium.

@kevinsawicki
Copy link
Contributor Author

kevinsawicki commented Jun 22, 2016

One of the main benefits of doing this would have been automatic localization. Doesn't look like this PR handles that.

Nope, that will be handled in a subsequent up pull request. 🌎

about: {
get label () {
const {app} = require('electron')
return `About ${app.getName()}`
Copy link
Contributor

Choose a reason for hiding this comment

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

Should be:

process.platform === 'linux' ? 'About' : `About ${appName}`

On Linux, they don't include the app name.

@sindresorhus
Copy link
Contributor

// @danhp

@kevinsawicki
Copy link
Contributor Author

kevinsawicki commented Jun 22, 2016

@sindresorhus thanks for the review, I've incorporated your feedback 👍

@kevinsawicki kevinsawicki force-pushed the default-label-and-accelerator branch from 35f0490 to 813e528 Compare June 22, 2016 22:41
@sindresorhus
Copy link
Contributor

LGTM

},
togglefullscreen: {
label: 'Toggle Full Screen',
accelerator: process.platform === 'darwin' ? 'Ctrl+Command+F' : 'F11',
Copy link
Contributor

Choose a reason for hiding this comment

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

Ctrl -> Control

@danhp
Copy link
Contributor

danhp commented Jun 22, 2016

Aside from the tiny nitpick, it looks good.

@zcbenz
Copy link
Member

zcbenz commented Jun 23, 2016

👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants