Fix key shortcuts and context menu
holandes22 opened this issue · 0 comments
There is currently kind of a mess with shortcuts, menu and context-menu This ticket is to layout the possible ways we can fix/refactor the code dealing with this thing.
Shortcuts
Some shortcuts like "toggle full screen", "toggle developer tools" and "reload" do not work in the packaged version until you add an application menu (pointed to me by the ember-electron creator here adopted-ember-addons/ember-electron#75).
In order to make those shortcuts work we have some options:
- Add an application menu (I like this the least as it changes completely the look of the app by having an extra menu on top of the nav bar)
- Use something like this package https://github.com/parro-it/electron-localshortcut to register shortcuts
- On top of adding the shortcuts we could add our own menu in the navbar, and triggering different actions that will act upon the window: For example
requireNode('remote').getCurrentWindow().toggleDevTools();
to toggle dev tools
Context Menu
The context menu event is supposed to work from the main process (electron.js) but this wasn't working (see #26) after packaging. Currently I added an ugly hack of adding an event listener within the app route (for some reason it works within the rendered process with remote).
Some options
- This might be a bug in ember-electron (context-menu works on the main process with the quick-start project after packaging) in which case a fix over there is needed. Here is the ticket adopted-ember-addons/ember-electron#71
- Use ember event handlers https://guides.emberjs.com/v2.6.0/components/handling-events/ to listen for contextMenu instead of attaching directly to window
Also, limit options in context menu to editing stuff (copy/paste/undo/redo, etc.) and put stuff like toggle dev tools and full screen in main menu