Skip to content

[Regression] Can't add a hotkey to a custom control #12323

Closed
@flexxxxer

Description

@flexxxxer

Describe the bug
Registration of hotkeys for controls that do not implement Avalonia.Input.IClickableControl is not possible.

To Reproduce
Example with working hotkey registration for custom type HotKeyedTextBox inherited from Avalonia.Controls.TextBox for Avalonia v0.10.21 and not working hotkey registration for custom type HotKeyedTextBox inherited from Avalonia.Controls.TextBox for Avalonia V11 here.

But in general:

  1. Create custom control which not implementing Avalonia.Controls.TextBox or not inherits from Avalonia.Controls types which implements Avalonia.Input.IClickableControl (examples: Window, UserControl, TextBox, TextBlock, PathIcon, ListBox, etc).
  2. Implement HotKeyProperty and HotKey like Avalonia.Controls.Buttons
  3. Implement ICommandSource where in Command will be your hotkey logic (implementation of Avalonia.Input.IClickableControl not possible due protection level).

Expected behavior
Hotkey working.

Screenshots
Below reproduction using samples from here.
https://github.com/AvaloniaUI/Avalonia/assets/44833369/2423270f-8b14-4a4d-aac2-968a20d2f250

Desktop:

  • OS: Windows
  • Version: 0.10.21 and 11.0.0

Additional context
PR that broke the working functionality is #7500

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions