5
0
mirror of https://github.com/wailsapp/wails.git synced 2025-05-04 04:11:56 +08:00

[windows] Prevent WebView2 from processing keystrokes

This commit is contained in:
Lea Anthony 2021-07-18 19:02:33 +10:00
parent b86d2fe8cd
commit 5d2cc81123

View File

@ -55,14 +55,14 @@ class wv2ComHandler
// This is our keyboard callback method // This is our keyboard callback method
HRESULT STDMETHODCALLTYPE Invoke(ICoreWebView2Controller *controller, ICoreWebView2AcceleratorKeyPressedEventArgs * args) { HRESULT STDMETHODCALLTYPE Invoke(ICoreWebView2Controller *controller, ICoreWebView2AcceleratorKeyPressedEventArgs * args) {
// Prevent WebView2 from processing the key
args->put_Handled(TRUE);
COREWEBVIEW2_KEY_EVENT_KIND kind; COREWEBVIEW2_KEY_EVENT_KIND kind;
args->get_KeyEventKind(&kind); args->get_KeyEventKind(&kind);
if (kind == COREWEBVIEW2_KEY_EVENT_KIND_KEY_DOWN || if (kind == COREWEBVIEW2_KEY_EVENT_KIND_KEY_DOWN ||
kind == COREWEBVIEW2_KEY_EVENT_KIND_SYSTEM_KEY_DOWN) kind == COREWEBVIEW2_KEY_EVENT_KIND_SYSTEM_KEY_DOWN)
{ {
// Prevent WebView2 from processing the key
args->put_Handled(TRUE);
UINT key; UINT key;
args->get_VirtualKey(&key); args->get_VirtualKey(&key);
COREWEBVIEW2_PHYSICAL_KEY_STATUS status; COREWEBVIEW2_PHYSICAL_KEY_STATUS status;