max-mapper / menubar

➖ high level way to create menubar desktop applications with electron
BSD 2-Clause "Simplified" License
6.67k stars 366 forks source link

Menu shouldn't be shown on double click if showOnRightClick is true #168

Open jamieweavis opened 7 years ago

jamieweavis commented 7 years ago

When the showOnRightClick config option is true, the menubar probably shouldn't be shown when double clicking the tray icon.

The showOnRightClick option will most likely be used when developers wish to use the click event for other purposes. For example a single click could show a BrowserWindow while right-click would show the menubar which contains preferences for their application. In this use-case double clicking the tray icon would show both the BrowserWindow and the menubar at the same time.

This could also potentially be addressed by adding a new config option to disable the double-click event being added to the tray. However I can't think of a use-case where you would want the menubarto show on right-click & double-click but not single click. So I would suggest not adding the double-click event if the showOnRightClick config option is true.

I'll create a pull request tomorrow.

amaury1093 commented 5 years ago

I'm thinking about adding the following options:

{
  onClick: 'toggle' | () => void, // defaults to 'toggle'
  onDoubleClick: 'toggle' | () => void, // defaults to noop
  onRightClick: 'toggle' | () => void, // defaults to noop
}

'toggle' just means the window will show/hide. But if the developer wants to customize, he/she can put any click handler on these events.

This will also deprecate the showOnRightClick option, since {showOnRightClick: true} -> {onRightClick: 'toggle'}

What do you think?

amaury1093 commented 5 years ago

@jamieweavis Would you like to continue on your PR, or should I take care of this?

jamieweavis commented 5 years ago

Feel free to continue @amaurymartiny 👍