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

Feature: Signal to Renderer to open Electron-Webview DevTools #37

Open
ghost opened this issue May 20, 2016 · 7 comments
Open

Feature: Signal to Renderer to open Electron-Webview DevTools #37

ghost opened this issue May 20, 2016 · 7 comments

Comments

@ghost
Copy link

ghost commented May 20, 2016

A useful feature it would be if a signal is sent to the renderer process. Because then you can decide in Electron-Webview whether this also wants to open the DevTools.

@sindresorhus
Copy link
Owner

Why? Not sure I understand the use-case.

@ghost
Copy link
Author

ghost commented May 20, 2016

To Debug external Websources. In my case an Ionic WebApp

@sindresorhus
Copy link
Owner

But you can just use the shortcut or enable the option to open devtools automatically on startup. Maybe it would help if you provided an example usage.

@ghost
Copy link
Author

ghost commented May 20, 2016

The shortcut openes only the DevTools from electron.BrowserWindow.
In the Renderer Process you can use the Electron Webview tag see api docs

An Example:

Main process

let win = new BrowserWindow({width: 800, height: 600, show: false});
win.on('closed', () => {
  win = null;
});

win.loadURL('file://index.html');
win.show();

Renderer Process: index.html

<html>
<body>
<webview id="view" src="web.whatsapp.com" />

<script>
const {ipcRenderer} = require('electron');


  $('#view')[0].addEventListener('dom-ready', function () {

    ipcRenderer.on('dev-tools-opened', (event, arg) => {
      $('#view')[0].openDevTools();
    });
  });
</script>

</body>
</html>

The dev-tools-opened Signal is fired from the openDevTools method

@sindresorhus
Copy link
Owner

Thanks for elaborating. Makes sense. I wonder though if there's any way we can handle that more automagically. Like maybe allow you to pass in the webview DOM element to electron-debug and have it handled for you? Ideas?

@parro-it
Copy link
Contributor

Trying to solve parro-it/debug-menu#6 I made some experiment using webContents.getFocusedWebContents(). It return webContents of webviews when they are focused.

I remember of this issue... I think it could be elegantly solved using getFocusedWebContents.

@motin
Copy link

motin commented Jul 21, 2018

@parro-it I followed your advice and implemented #64, thanks :)

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

No branches or pull requests

3 participants