Skip to content
This repository has been archived by the owner on Dec 11, 2019. It is now read-only.

Add the ability to close developer tools via keyboard shortcut on macOS #45

Closed
bbondy opened this issue Dec 11, 2015 · 34 comments
Closed

Comments

@bbondy
Copy link
Member

bbondy commented Dec 11, 2015

After opening content dev tools, you can't use the local shortcut to close them again.
STR:

  1. Command+Option+I to open dev tools
  2. Command+Option+I to close dev tools

Expected results:
It closes even though the devtools window has focus

Actual results:
You need to focus back to the parent window first.

@bridiver maybe we need to register with localShortcut the devtools window?

@bbondy bbondy added the bug label Dec 11, 2015
@bridiver
Copy link
Collaborator

cmd+shift+J works to toggle on and off, but I'm not sure why the menu accelerator wouldn't work. Seems to work fine for other "focusedWindow" shortcuts

@bbondy
Copy link
Member Author

bbondy commented Dec 11, 2015

J will work because it's the same window. For client devtools electron has it hard coded to always open in a new window. And that window isn't registered for local shortcuts.

@bridiver
Copy link
Collaborator

yea, I bet it gets unregistered when the window re-renders and the shortcut doesn't make it back in

@bridiver
Copy link
Collaborator

the other shortcuts are registered in both places

@bbondy
Copy link
Member Author

bbondy commented Dec 11, 2015

I don't think we register the devtools window at all. I think it is considered different than the browser windows and local shortcuts doesn't know about them.

@bridiver
Copy link
Collaborator

Oh I see now, the problem is when the dev tools opens up in its own window. CMD-W is also an issue there and causes and error

@bridiver bridiver self-assigned this Dec 11, 2015
@bridiver
Copy link
Collaborator

this ended up being much more complicated than it seemed, but I think I can fix it using the devtools-focused event

@bridiver
Copy link
Collaborator

actually it looks like it will require a patch to electron. This is also broken in the Atom Editor

@bbondy
Copy link
Member Author

bbondy commented Dec 12, 2015

ok probably not worth the extra effort for now.

@bridiver
Copy link
Collaborator

yea, I'm just going to fix the crash for cmd-w

@bridiver
Copy link
Collaborator

I think this should be enough to get it working electron/electron#3783

@bbondy
Copy link
Member Author

bbondy commented Dec 16, 2015

Command+W does get fired btw from when you have the devtools window focused.
I added a console.log inside app.menu.js.

But we'd need to send a different event instead of firing shortcut-close-frame.

I think localShortcuts still won't work though, but menu ones should.

@bridiver
Copy link
Collaborator

might be a little tricky to handle because there can be multiple dev windows open for the same window and I don't think we can currently tell which one has focus

@bbondy
Copy link
Member Author

bbondy commented Dec 18, 2015

true not sure if there's a property to link it up to the opened from window.
In any case let's just punt on this one for now.

@bridiver
Copy link
Collaborator

we could use this:

  @webContents.on 'devtools-focused', => @emit 'devtools-focused'
  @webContents.on 'devtools-opened', => @emit 'devtools-opened'
  @webContents.on 'devtools-closed', => @emit 'devtools-closed'

@LoloIrie
Copy link

LoloIrie commented Mar 7, 2016

BTW, shortcut for the dev tool should be F12 like other browsers

@bbondy
Copy link
Member Author

bbondy commented Apr 6, 2016

@LoloIrie F12 added for 0.9.0.
Leaving this open for the original issue though.

@bbondy
Copy link
Member Author

bbondy commented Apr 6, 2016

Yep I'm aware of that one as well but pls ask any questions about its prioirty in the context of that bug.

@weems
Copy link

weems commented Apr 6, 2016

@bbondy thanks.

@alexwykoff
Copy link
Contributor

Still an issue in 0.12.8. Prioritizing to 1.2

@alexwykoff alexwykoff added this to the 1.2.0 milestone Nov 9, 2016
@antiroyalty
Copy link
Contributor

+1 on request for cmd+W to close dev tools window

@bbondy bbondy changed the title Add the ability to close developer tools via keyboard shortcut Add the ability to close developer tools via keyboard shortcut on macOS May 18, 2017
@bbondy
Copy link
Member Author

bbondy commented May 18, 2017

@luixxiul @srirambv @alexwykoff
Turn out the fix applied here will only work on macOS because it works via sending a Window shortcuts and only on mac is the shortcuts app level.

I renamed the title for this to be specific to mac and I posted a new issue here to track the work on the other platforms:
#8935

Please test this only on mac.

@bbondy bbondy closed this as completed May 18, 2017
@luixxiul luixxiul removed the needs-info Another team member needs information from the PR/issue opener. label May 19, 2017
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.