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

How can I set the Developer menu to open devTools? #22

Open
janckerchen opened this issue Oct 31, 2024 · 2 comments
Open

How can I set the Developer menu to open devTools? #22

janckerchen opened this issue Oct 31, 2024 · 2 comments

Comments

@janckerchen
Copy link

janckerchen commented Oct 31, 2024

I can open it from the right-click menu with "Inspect Element", but it's inconvenient, I want to open the console directly to see the logs. The shortcut cmd+opt+I doesn't work either. How do I set up a menu or set up a shortcut?

Browser console logs, is it possible to print them to the command line console ?

I tried the following code but it doesn't work.

ApplicationMenu.setApplicationMenu([
  
  {
    label: "Developer",
    submenu: [
      {
        label: "Toggle Developer Tools",
        role: "toggleDevTools"
        accelerator: process.platform === "darwin" ? "Cmd+Alt+I" : "Ctrl+Shift+I",
      },
    ],
  },
]);
@YoavCodes
Copy link
Member

YoavCodes commented Nov 1, 2024

Adding the cmd+opt+i shortcut is on my todo list. Let's keep this issue open to track that.

As far as I can tell there's no default role that macos automatically wires up, that's a Safari behaviour but not a WKWebkit feature. Especially since technically an application menu can be shown for an application with multiple Webviews it wouldn't know which one to inspect.

So I believe this is functionality I need to add into electrobun's objc code to support it.

I'd want to:

  • support keyboard shortcut to open devtools for the current window's main webview
  • add a property in BrowserView({ showDevtoolsOnStartup: true }) so you can automatically open it as soon as the window's BrowserView initializes

@YoavCodes
Copy link
Member

I'm actually not sure that WKWebkit has a programmatic way (in objc or otherwise) to launch devtools.

So this might only be something we can enable in the future when we add the option to bundle a webview (like chromium) with your electrobun app or maybe when we support window's development since the system webview on windows is Edge which is chromium based and I think has an api to open devTools programmatically.

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

2 participants