-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
Why do Wpf TextBoxes only mark some Events as Handled #10138
Comments
Because for example if you handle PreviewKeyDownEvent, the KeyDownEvent is not raised anymore. But also if a parent mousewheel event is handled, subscribers for a child control mousewheel event are not notified as well. Therefore it would be ridiculous if the framework marks all events as handled. When to mark such an event as handled is described here |
That is a good find, Symbai, for reference. I think the answer is a bit simpler though: The TextBox does not actually handle these events for typing. Typing happens as a result of text composition and that's what gets handled. |
Thank you for your response. I understand that the PreviewKeyDownEvent is not marked handled. I would expect that KeyDownEvent is handled, but you could argue that it is enough that TextCompositionEventArgs is marked handled.
It also seems inconsistent that the OnSpace method marks the event as handled but the OnDelete not. |
Yes, text composition seems understandable for normal characters. But what is with the commands like Delete/Space? They are not marked handled consistently |
Description
I work on some Interaction Detection and use the fact that Controls mark RoutedEvents as Handled when they handle them.
Unfortunately, TextBoxes only mark
TextCompositionEventArgs
in theOnTextInput
method andExecutedRoutedEventArgs
in theOnSpace
as Handled (see TextEditorTyping.cs#L386). All other Events (Delete, Key Events, ...) that are also implemented inTextEditorTyping
are not marked as handled. Is there a Reason for that? It is a problem for my usecase.Reproduction Steps
Register a ClassHandler for handled Events and debug what Controls handle the events.
Expected behavior
TextBoxes handle all Events that change its text.
Actual behavior
TextBoxes only mark
TextCompositionEventArgs
in theOnTestInput
method andExecutedRoutedEventArgs
in theOnSpace
as Handled.All common KeyEvents do not mark events as Handled, as well as all other event handling methods OnBackspace, OnDelete, OnToggleInsert, ...
TextEditorTyping.cs#L386
Regression?
No response
Known Workarounds
No response
Impact
No response
Configuration
Not configuration specific as far as I know, but the target framework is net80-windows
Other information
No response
The text was updated successfully, but these errors were encountered: