wry
wry copied to clipboard
CustomMenuItem accelerators don't trigger on_menu_event on Windows
Describe the bug
CustomMenuItem accelerators in Windows don't trigger on_menu_event, though they do in macOS.
To Reproduce
Steps to reproduce the behavior:
- Clone minimal example repository here.
- Set up and run app (I use
yarn installandyarn tauri dev). - Click File -> Test and note output in terminal. ("test" Test registered!)
- Press Ctrl + T and note that output does not appear in terminal.
Expected behavior
Both clicking the menu item and triggering it via its accelerator produce output in the terminal on Windows, since both actions work on macOS.
Screenshots
NA
Platform and Versions (required):
Operating System - Windows, version 10.0.19042 X64
Webview2 - 96.0.1054.41
Node.js environment
Node.js - 16.13.0
@tauri-apps/cli - 1.0.0-beta.10
@tauri-apps/api - 1.0.0-beta.8
Global packages
npm - 8.1.0
yarn - 1.22.15
Rust environment
rustc - 1.56.1
cargo - 1.56.0
App directory structure
/.git
/node_modules
/public
/scripts
/src
/src-tauri
App
tauri.rs - 1.0.0-beta.8
build-type - bundle
CSP - default-src blob: data: filesystem: ws: wss: http: https: tauri: 'unsafe-eval' 'unsafe-inline' 'self' img-src: 'self'
distDir - ../public/
devPath - http://localhost:5555
framework - Svelte
Operating System - Mac OS, version 12.0.1 X64
Node.js environment
Node.js - 16.9.0
@tauri-apps/cli - 1.0.0-beta.10
@tauri-apps/api - 1.0.0-beta.8
Global packages
npm - 7.21.1
yarn - 1.22.15
Rust environment
rustc - 1.55.0
cargo - 1.55.0
App directory structure
/node_modules
/public
/scripts
/src-tauri
/.git
/src
App
tauri.rs - 1.0.0-beta.8
build-type - bundle
CSP - default-src blob: data: filesystem: ws: wss: http: https: tauri: 'unsafe-eval' 'unsafe-inline' 'self' img-src: 'self'
distDir - ../public/
devPath - http://localhost:5555
framework - Svelte
bundler - Rollup
good news, it works fine in Tao , bad news I can't find any reason why it is not working in Tauri but I can definitely replicate the issue.
Alright, I can replicate it in Wry, seems like the webview hijacks the keyboard events from the underlying win32 window procedure. I will transfer it to Wry.
Does it work if we set it to other shortcut? I think webview2 might occupy a few already. https://weblog.west-wind.com/posts/2021/Apr/15/WebView2-Forwarding-Alt-Keys-to-a-Host-WPF-Window
I have tried https://docs.microsoft.com/en-us/microsoft-edge/webview2/reference/win32/icorewebview2controller?view=webview2-1.0.664.37#add_acceleratorkeypressed but it didn't work. I will look at the article you linked and dig into this again.
Just took a look at the article and it can work (in a hacky way) for Alt only which is not perfect because I found out that sometimes Ctrl combinations don't work.
I will make this as upstream and wait until this is implemented
Being that this has been open since 2021, I wonder if it makes sense to document a workaround? I'm guessing doing something through the frontend Javascript API? Simple key strokes like Ctrl+S for saving don't even work.... Thats kinda a big deal...
hello,I encountered the same problem. Is there any progress on this issue?
Just took a look at the article and it can work (in a hacky way) for
Altonly which is not perfect because I found out that sometimesCtrlcombinations don't work.
Hey,
But up until now, the use of accelerators in tauri is null right, i.e., no functionality is added to them? Using Alt is just a substitution here, that too in Windows for exploring the menu-tray.