Skip to content

Handled not set correctly for copy/cut/paste keyboard actions #11555

Description

@benstevens48

Describe the bug

When listening to the InputKeyboardSource.KeyDown event KeyEventArgs.Handled is always true for Ctrl + C and Ctrl + X actions (and always false for Ctrl + P).

On the other hand, when listing to XamlRoot.Content.KeyDown, KeyRoutedEventArgs.Handled is always false in the same situation, even when text is being copied from a text box or text block with selection enabled.

In UWP I was able to listen to CoreWindow.KeyDown and the KeyEventArgs.Handled property was true when Ctrl + C and Ctrl + X actions resulted in text being copied to the clipboard from a TextBox or TextBlock etc. Thus I was able to implement a keyboard shortcut at the window level for copying the currently visible image in my app without interfering with copy/cut shortcuts in text box/text block controls by looking at the handled property. Now I have to use a workaround using the FocusManager to see if a text control has focus (and in the case of TextBlock/RichTextBlock whether it has any selected text or not).

Please can this be fixed so the Handled property is set correctly (if and only if the event has been handled!).

Steps to reproduce the bug

See description.

Expected behavior

No response

Screenshots

No response

NuGet package version

2.4

Packaging type

Packaged (MSIX)

Windows version

Windows 11 version 24H2 LTSC (26100, June Update)

IDE

No response

Additional context

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    needs-triageIssue needs to be triaged by the area owners

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions