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

Devtools hotkey #2915

Merged
merged 16 commits into from Sep 18, 2023
Merged

Devtools hotkey #2915

merged 16 commits into from Sep 18, 2023

Conversation

leaanthony
Copy link
Member

Description

This PR adds an F12 hotkey shortcut to open the devtools window, whenever the app is built with the devtools flag.
Not sure if this could be an issue for signed apps... I don't think it is...

Fixes #2908

Type of change

  • New feature (non-breaking change which adds functionality)

How Has This Been Tested?

Create a new project, build with wails build and check F12 does nothing. Build with wails build -devtools and press F12.

  • Windows
  • macOS
  • Linux

Checklist:

  • I have updated website/src/pages/changelog.mdx with details of this PR
  • My code follows the general coding style of this project
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes

@cloudflare-pages
Copy link

cloudflare-pages bot commented Sep 16, 2023

Deploying with  Cloudflare Pages  Cloudflare Pages

Latest commit: 6e05fab
Status:⚡️  Build in progress...

View logs

@mmghv
Copy link
Contributor

mmghv commented Sep 16, 2023

Works as expected on windows.

Now that F12 opens the devtools, maybe -devtools shouldn't enable the default contextmenu? so only EnableDefaultContextMenu option enables it in production.

@leaanthony
Copy link
Member Author

I'm open to discussion on this. The only edge case is Mac apps that want it enabled and want it on the appstore (does that combo even make sense???).

@mmghv
Copy link
Contributor

mmghv commented Sep 16, 2023

Can't speak for Mac devs, but if I understand correctly there's no way around it if you want F12 or a runtime method to open it.

Honestly F12 makes a lot of sense and makes life easier, it also solves the default contextmenu problem because now you don't have to show it with -devtools.

Copy link
Collaborator

@stffabi stffabi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, should we also warn in build.go that private APIs are being used on macOS when build-tag devtools is used?

if options.Platform == "darwin" && options.Mode == Debug {
pterm.Warning.Println("A darwin debug build contains private APIs, please don't distribute this build. Please use it only as a test build for testing and debug purposes.")
}

@leaanthony
Copy link
Member Author

I've changed the key combination to CTRL/CMD+SHIFT+F12 to make it less likely to clash with current bindings.

@leaanthony
Copy link
Member Author

@mmghv - I've removed what I think is the right code to stop devtools enabling the default context menu. It looks like it was only enabled in Windows?

@mmghv
Copy link
Contributor

mmghv commented Sep 18, 2023

I've removed what I think is the right code to stop devtools enabling the default context menu. It looks like it was only enabled in Windows?

No it exists in all platforms but each with it's own way, also what you changed disabled the default context-menu on windows in debug & dev, revert it and I'll do it along with some relevant docs changes in a separate PR after you merge this.

@@ -499,7 +511,7 @@ func (f *Frontend) setupChromium() {
if err != nil {
log.Fatal(err)
}
err = settings.PutAreDefaultContextMenusEnabled(f.devtools || f.frontendOptions.EnableDefaultContextMenu)
err = settings.PutAreDefaultContextMenusEnabled(f.frontendOptions.EnableDefaultContextMenu)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This change disables the default context-menu on windows in dev & debug because f.devtools is enabled for -devtools, -debug and dev mode.

@leaanthony
Copy link
Member Author

Will do tomorrow 👍

@leaanthony
Copy link
Member Author

@mmghv - change reverted 👍

@leaanthony leaanthony merged commit 6aa6762 into master Sep 18, 2023
3 of 4 checks passed
@leaanthony leaanthony deleted the devtools_hotkey branch September 18, 2023 19:56
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

Successfully merging this pull request may close these issues.

Right click to open inspector does not work when build is generated with -devtools flag only
3 participants