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 option to open DevTools #32

Open
parro-it opened this issue Feb 27, 2016 · 9 comments
Open

Add option to open DevTools #32

parro-it opened this issue Feb 27, 2016 · 9 comments

Comments

@parro-it
Copy link
Contributor

The more I use electron-debug, the more I'm annoyed by this use case.
I open DevTools with toggle shortcut, then often it got covered by other windows, but still open.
After a while, I often forgot it is open and I press toggle key to show DevTools, but since it's already opened, it close.

I think it should be useful to add an option to just open it if closed, or otherwise focus it.
I don't think there is a specific method in electron to focus, we could ask for it (or maybe it could suffice to re-open it, I have to try).

@sindresorhus
Copy link
Owner

Can't say that's been an issue for me, but I'm open to adding something for this. The downside of adding it as an option is that it would permanently remove ability to close dev tools from the keyboard. Wouldn't it be better to just add an alternative keyboard shortcut?

I don't think there is a specific method in electron to focus

I think you can focus this http://electron.atom.io/docs/v0.36.8/api/web-contents/#webcontentsdevtoolswebcontents

@parro-it
Copy link
Contributor Author

Wouldn't it be better to just add an alternative keyboard shortcut?

Yes, I mean to add a new shortcut, keeping all existing stuff, that is still useful

@parro-it
Copy link
Contributor Author

I think you can focus this http://electron.atom.io/docs/v0.36.8/api/web-contents/#webcontentsdevtoolswebcontents

Already tried, but BrowserWindow.fromWebContents always return null for a DevTools window, so no luck there.

@sindresorhus
Copy link
Owner

Already tried, but BrowserWindow.fromWebContents always return null for a DevTools window, so no luck there.

Ok. Can you open an Electron issue and cross-link it here?

@sindresorhus
Copy link
Owner

Yes, I mean to add a new shortcut, keeping all existing stuff, that is still useful

👍

@parro-it
Copy link
Contributor Author

Ok. Can you open an Electron issue and cross-link it here?

Sure!

@parro-it
Copy link
Contributor Author

parro-it commented Mar 5, 2016

My issue on Electron appear to be blocked by this other.

I done some experiments here but they are unfortunate...

I published a version of the method that close and re-open DevTools directly on debug-menu, I will refactor that when upstream issue is solved and then move it to electron-debug.

@vinnymac
Copy link

vinnymac commented Sep 9, 2016

@parro-it If I read this issue correctly, all you want to do is open dev tools when they are closed, focus them when they are open.

I do this in my app already, see below.

const firstWindow = BrowserWindow.getAllWindows()[0]
if (!firstWindow) return

const isDevToolsOpened = firstWindow.isDevToolsOpened()
const isDevToolsFocused = firstWindow.isDevToolsFocused()

if (isDevToolsOpened && isDevToolsFocused) {
  firstWindow.closeDevTools()
} else if (isDevToolsOpened && !isDevToolsFocused) {
  firstWindow.devToolsWebContents.focus()
} else {
  firstWindow.openDevTools()
}

You could remove the first test if you don't want it closing on you. I use this with the Shift+Ctrl/Cmd+I shortcuts and it hasn't given me any trouble so far.

@sindresorhus
Copy link
Owner

Alright, let's do this by default when the DevTools is undocked. Apparently, that's how the native Chrome DevTools work too.

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

3 participants