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

Global shortcuts trigger twice #3739

Open
Skippeh opened this issue Feb 14, 2025 · 0 comments · May be fixed by #3741
Open

Global shortcuts trigger twice #3739

Skippeh opened this issue Feb 14, 2025 · 0 comments · May be fixed by #3741
Labels
bug Something isn't working

Comments

@Skippeh
Copy link

Skippeh commented Feb 14, 2025

Problem

When using dioxus_desktop::hooks::use_global_shortcut, the handler is called twice. Once when the key is pressed, and once when it's released.

This bug probably got introduced when the global-hotkey crate was updated to 0.4.0, as that version's change log mentions adding key state to the event: https://github.com/tauri-apps/global-hotkey/releases/tag/global-hotkey-v0.4.0

The source of the problem lies here:

pub(crate) fn call_handlers(&self, id: GlobalHotKeyEvent) {

The id: GlobalHotKeyEvent parameter has a field that says if the shortcut was pressed or not. It is not used in the function or passed onto handlers.

Steps To Reproduce

Steps to reproduce the behavior:

  • Add a global shortcut using use_global_shortcut
  • When triggered, the event is called both on press and release

Running the shortcut example project also displays the incorrect behavior.

Expected behavior

The event should only be called when pressed, or for a future breaking change the pressed state should be passed to the event handler.

Environment:

  • Dioxus version: 0.6.3
  • Rust version: 1.84.1
  • OS info: Windows 11 23H2
  • App platform: desktop
@Skippeh Skippeh added the bug Something isn't working label Feb 14, 2025
@Skippeh Skippeh linked a pull request Feb 15, 2025 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant