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]: add a setting to CoreWebView2Settings to enable Ctrl+F find #4639

Open
pushkin- opened this issue Jun 19, 2024 · 12 comments
Open
Labels
feature request feature request

Comments

@pushkin-
Copy link

Describe the feature/enhancement you need

I want to enable the Ctrl+F find popup without enabling all other accelerator keys. Currently, it seems like I have to set AreBrowserAcceleratorKeysEnabled to get Ctrl+F to work.

The scenario/use case where you would use this feature

Don't want other keys to get handled.

Ideally, we could intercept those keys and handle them to get, for example Ctrl+R to not refresh the page, but sometimes our webapp might want to handle the event and setting e.Handled = true prevents the page from getting the event.

How important is this request to you?

Impactful. My app's user experience would be significantly compromised without it.

Suggested implementation

Similar to how we have a IsZoomControlEnabled to get Ctrl + +/- to work, I'd like a similar setting to get Ctrl+F to work without enabling everything else.

What does your app do? Is there a pending deadline for this request?

will have to implement the Find popup myself instead which is costly. by sometime EOY

@pushkin- pushkin- added the feature request feature request label Jun 19, 2024
@ajtruckle
Copy link

You know that they are working on a custom Find API? It is still at development stage I think. Not sure of ETA.

@pushkin-
Copy link
Author

@ajtruckle I know that. Briefly glanced at it. Wasn't sure if they were proposing adding a Setting that will enable that accelerator by default. Didn't see that. Just thought it was concerned with adding APIs to show/find programmatically.

@victorhuangwq victorhuangwq assigned srwei and unassigned srwei Jun 25, 2024
@victorhuangwq
Copy link
Collaborator

victorhuangwq commented Jun 25, 2024

As @ajtruckle mentioned, there is indeed a Find API in the works. It allows you to programmatically launch the find feature. This works independently of accelerator keys.

https://github.com/MicrosoftEdge/WebView2Feedback/pull/4399/files?short_path=a4e657f#diff-a4e657fb3aef3cc7b9a09b13af805de25931fdb082b2a93aeea46e45de10bb90

If your main purpose is for you to launch the Find popup, this would definitely work for this use case.

@pushkin-
Copy link
Author

@victorhuangwq ok, so I'd still have to intercept Ctrl+F and call this API though, right? I was hoping there could be a setting that would automatically make Ctrl+F trigger the Find popup.

Additionall, the problem with intercepting it myself and setting e.Handled = true is that that prevents the web app code from getting the Ctrl+F hotkey. That might be ok in general, but it might be nice that if web code was listening for Ctrl+F, it got that event before the host app did.

@ajtruckle
Copy link

ajtruckle commented Jun 25, 2024 via email

@pushkin-
Copy link
Author

@ajtruckle My understanding is that Ctrl+F works because Settings::EnableBrowserAcceleratorKeys defaults to true. In my case, I don't want to enable all other accelerator keys, just ctrl+f so was looking for a separate setting to just control that one hotkey.

@ajtruckle
Copy link

ajtruckle commented Jun 25, 2024 via email

@pushkin-
Copy link
Author

@ajtruckle My issue is that I don't want to blanket supress all other hotkeys. From my testing, if I suppress a hotkey at the host level (in a KeyDown event handler), it prevents the page I'm loading in the WebView2 control from getting the hotkey. If the page wants to handle the hotkey, I want it to get an opportunity to do so.

@ajtruckle
Copy link

ajtruckle commented Jun 25, 2024 via email

@ajtruckle
Copy link

ajtruckle commented Jun 25, 2024 via email

@victorhuangwq
Copy link
Collaborator

@pushkin- if all you want is to have Ctrl-F open up the find dialog, would the following be a viable approach?

  • Set Settings::EnableBrowserAcceleratorKeys to false
  • Handle Ctrl-F in the AcceleratorKeyPressed event, since

This setting has no effect on the AcceleratorKeyPressed event. The event will be fired for all accelerator keys, whether they are enabled or not.

  • Use the Find API to launch Find Dialog

@pushkin-
Copy link
Author

@victorhuangwq I need to wait for the FInd API to be released first for that to work.

Also, I'm not using an AcceleratorKeyPressed event but the KeyDown event on the Control. I thought I read somewhere that AcceleratorKeyPressed isn't available anymore, or exists on the Controller or something which we might not have access to.

Regardless, this might work, but would I not have the same issue I mention above where if I handle an event at the host level (e.Handled = true), then the webapp won't receive those events (since host process gets them before WebView2 site?)

If there were a setting that would send the key presses to the webview2 control first and if they weren't handled/prevented there, then the host app would get the accelerator key press, that would be ideal.

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

No branches or pull requests

4 participants