Skip to content

HotKeys still work on hidden buttons and swallow keyboard input #21708

Description

@SomeeName

Describe the bug

If you hide a panel or a menu (IsVisible="False") that contains a button with a HotKey shortcut assigned to it (for example, HotKey="Escape"), the shortcut key still triggers globally.

When you press that key anywhere else in the app, the invisible button still runs its code and "steals" the key press which partically stops the key from working properly anywhere else in the rest of the application.

To Reproduce

  1. Put a Button inside a hidden layout container (set IsVisible="False" on the parent panel).
  2. Assign a shortcut key to that button, like HotKey="Escape".
  3. Press Escape while working in a completely different, visible part of the app.

Expected behavior

The application should ignore HotKey bindings for controls that are not effectively visible or enabled.

Avalonia version

12.0.5

OS

Windows

Additional context

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions