KeyModifiers in button click event
See original GitHub issueIs your feature request related to a problem? Please describe. It is a common use case to identify any modifier key is pressed when a button is clicked, either with pointer or keyboard. In button definition, both PointerEventArgs and KeyEventArgs carries KeyModifiers, but when forwarding to OnClick method, this information is lost. It would be helpful to pass this information to OnClick method, otherwise I have to override all key/pointer methods when inheriting from Button.
Describe the solution you’d like
class ClickEventArgs:RoutedEventArgs
{
public KeyModifiers KeyModifiers { get; }
}
internal interface IClickableControl
{
event EventHandler<ClickEventArgs> Click;
}
Describe alternatives you’ve considered
Additional context my actual use case:
protected override void OnApplyTemplate(TemplateAppliedEventArgs e)
{
base.OnApplyTemplate(e);
var button = e.NameScope.Find<RepeatButton>("PART_Button");
button.Click += OnButtonClick;
}
private void OnButtonClick(object? sender, RoutedEventArgs args)
{
// When Shift is pressed, use logic 1, else use logic 2.
}
``
Issue Analytics
- State:
- Created a year ago
- Comments:9 (7 by maintainers)
Top Results From Across the Web
Event Handling | Vue.js
Inline handlers: Inline JavaScript to be executed when the event is triggered (similar to the native onclick attribute). Method handlers: A property name...
Read more >Triggering click event with modifier keys on input element
I'm writing a test for some functionality that involves user shift-clicking on a checkbox. I'm using $('input').trigger($.Event('click', { ...
Read more >KeyboardEvent: getModifierState() method - Web APIs | MDN
The KeyboardEvent.getModifierState() method returns the current state of the specified modifier key: true if the modifier is active (that is ...
Read more >Vue Event Modifiers
The event modifier .once can be used after both keyboard and mouse click events. Keyboard Key Event Modifiers. We have three different keyboard...
Read more >Check which modifier key is pressed - Windows Forms .NET
When a modifier key is pressed in combination with other keys or even a mouse click, your application can respond appropriately. For example...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@rabbitism as discussed, we think it’s a good idea to have RoutedEventArgs.Inner.
@maxkatz6 i will think about it. Inner need to be immutable, or there will be infinite loop when getting most inner exception.