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

CustomMenuItem accelerators don't trigger on_menu_event on Windows #451

Open
adamthrash opened this issue Dec 3, 2021 · 9 comments
Open

Comments

@adamthrash
Copy link

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:

  1. Clone minimal example repository here.
  2. Set up and run app (I use yarn install and yarn tauri dev).
  3. Click File -> Test and note output in terminal. ("test" Test registered!)
  4. 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
@amrbashir
Copy link
Member

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.

@amrbashir
Copy link
Member

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.

@amrbashir amrbashir transferred this issue from tauri-apps/tauri Dec 4, 2021
@wusyong
Copy link
Member

wusyong commented Jan 25, 2022

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

@amrbashir
Copy link
Member

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.

@amrbashir
Copy link
Member

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.

@amrbashir
Copy link
Member

I will make this as upstream and wait until this is implemented

@tr3ysmith
Copy link

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...

@kitty-eu-org
Copy link

hello,I encountered the same problem. Is there any progress on this issue?

@praball
Copy link

praball commented Apr 8, 2024

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.

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: 📬Proposal
Development

No branches or pull requests

6 participants