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

Native menu keyboard shortcuts #367

Closed
pauliusuza opened this issue Jan 18, 2013 · 25 comments
Closed

Native menu keyboard shortcuts #367

pauliusuza opened this issue Jan 18, 2013 · 25 comments

Comments

@pauliusuza
Copy link

I would like to display the corresponding keyboard shortcut for an item menu, currently there is no method in native menu api to do this:

menu_shortcuts

Proposed API should take into account 2 new optional parameters:

MenuItem.displayKey   (for example "Ctrl-\u2212")
MenuItem.key   (for example "Ctrl--")
@donaldpipowitch
Copy link

+1
That would be a very nice addition.

@sindresorhus
Copy link

👍

@mrsimonemms
Copy link

+1 from me.

Has any work been done on this as yet?

@jtenner
Copy link

jtenner commented Oct 9, 2013

On native

There are already libraries that do this kind of thing in javascript.

However, if presented with a native node-webkit api, I would probably use it.

@mrsimonemms
Copy link

Assigning the shortcuts isn't the issue. It's displaying the shortcuts in the menu bar that isn't possible (I believe)

@tommoor
Copy link

tommoor commented Nov 2, 2013

This would be a solid improvement

@keverw
Copy link

keverw commented Dec 17, 2013

+1 would be a really nice feature.

@gstf
Copy link

gstf commented Jan 11, 2014

+1

1 similar comment
@marekhrabe
Copy link

+1

@rpmadden08
Copy link

Hack solution: assign a keyboard shortcut through standard javascript. In the menu item label, manually type the associated keyboard shortcut yourself. Example: "file.append(new gui.MenuItem({label: "Open ⌘O"}));" You can add as many spaces between "Open" and "⌘O" as you need to make your menu items line up properly.

You can copy and paste any of the following symbols if it helps: ⌘ ⇧ ⌥.

@NodeGuy
Copy link

NodeGuy commented Jan 29, 2014

I had to set charset="UTF-8" on my script element for the ⌘ symbol to show up correctly:

<script src="script.js" charset="UTF-8"></script>

@Mithgol
Copy link
Contributor

Mithgol commented Jan 30, 2014

@NodeGuy Does your document have <meta charset="utf-8"> inside <head> . . . </head>?

@NodeGuy
Copy link

NodeGuy commented Jan 30, 2014

@Mithgol No. I imagine that would work too.

@albertogasparin
Copy link

Well, Mousetrap.js works really well.
In order to avoid encoding problems with the ⌘ symbol, I've used the unicode version.
So "Open... ⌘ O" is "Open... \u2318 O"

@serverwentdown
Copy link

I would like this native feature for node-webkit. Will make the app feel more native.

@davidmerfield
Copy link

For those using @rpmadden08's hacky solution, I wrote a script for generating menu labels with right aligned shortcuts:

http://jsfiddle.net/M6wt9/

Just plug in your menu items in the code on the left and then copy the labels from the demo on the right.

It uses hairspaces and thinspaces to get the alignment (almost) perfect. It also makes sure the '⌘' icons all line up even if you put another character (e.g. ⇧) in front.

@livedo
Copy link

livedo commented Aug 15, 2014

+1

@harrisitservices
Copy link

+1 - This would great! Can this please be implemented.

@elmsley
Copy link

elmsley commented Dec 4, 2014

+1, Seriously considering this framework for our project, more features the better!

@rogerwang
Copy link
Member

This feature was released in 0.10.0. See the release notes:

https://groups.google.com/d/msg/node-webkit/x7kYuDO0Cj8/cIxoJ6RFiLsJ

So close this issue. If you have any suggestions or bug reports, please report new issue. Thanks.

@elmsley
Copy link

elmsley commented Dec 5, 2014

I am not sure about mac, but on windows if I specify:
new gui.MenuItem({
label: 'Exit',
click: function() {
gui.Window.get().close();
},
key : 'x',
modifiers : "ctrl"
})

This does bind the ctrl-x sequence to this function. HOWEVER, it does not appear on the UI of the dropdown in my "Exit" menu item. It only displays "Exit", and not "Exit ctrl-x". This was the original request from pauliusuza. I don't believe this is resolved.

@pauliusuza
Copy link
Author

@rogerwang Thanks for adding this!

@TheTourer
Copy link

+1, this is not what OP requested. While the shortcuts work great, there is no UI support for them.

@jahlomp
Copy link

jahlomp commented May 22, 2015

+1

@Mithgol
Copy link
Contributor

Mithgol commented May 26, 2015

@TheTourer You should open a new issue about that; as @rogerwang said above,

If you have any suggestions or bug reports, please report new issue. Thanks.

And if (when) you open such new issue, please mention its number here.

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

No branches or pull requests