Atropo
Atropo

Reputation: 329

How to prevent showing source code in WebView2

I'm using WebView2 component for a hybrid app, and I've disabled the accelerator keys that show the DevTool window.

Unfortunately there is still the 'CTRL-U' hotkey that shows the source code of the page.

Is there a way to disable it?

Upvotes: 0

Views: 1456

Answers (1)

Atropo
Atropo

Reputation: 329

Found it!

In CoreWebView2Settings there is a property AreBrowserAcceleratorKeysEnabled that disables all "low level" hotkeys (also DevTools ones).

Just my opinion, but I find these settings counter-intuitive; I mean, I can disable DevTools with the property AreDevToolsEnabled (which removes both the entry in the context menu and the relative hotkeys), but yet programmatically invocable, and then there is also the AreBrowserAcceleratorKeysEnabled which disables every hotkeys (with the exception to text editing actions), but keeping the entry in the context menu for the DevTools.

Upvotes: 3

Related Questions