You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Nov 1, 2024. It is now read-only.
Key Events that happened outside of the control / before the control was created are not respected.
I might be wrong about 1.
My working modified version of ButtonClickEventTriggerBehavior is below, but I'm not really happy with the implementation as it involves setting event handlers on the top-level.
Is there a better way to archive this?
publicstaticclassModifierKeyStateProvider{publicstaticKeyModifiersModifierKeyState{get;set;}}publicclassButtonClickModifierKeyBehavior:Trigger<Button>{publicstaticreadonlyStyledProperty<KeyModifiers>KeyModifiersProperty=AvaloniaProperty.Register<ButtonClickModifierKeyBehavior,KeyModifiers>(nameof(KeyModifiers));publicKeyModifiersKeyModifiers{get=>GetValue(KeyModifiersProperty);set=>SetValue(KeyModifiersProperty,value);}protectedoverridevoidOnAttachedToVisualTree(){if(AssociatedObjectis not null){AssociatedObject.Click+=AssociatedObject_OnClick;}}protectedoverridevoidOnDetachedFromVisualTree(){if(AssociatedObjectis not null){AssociatedObject.Click-=AssociatedObject_OnClick;}}privatevoidAssociatedObject_OnClick(object?sender,RoutedEventArgse){if(AssociatedObjectis not null&&KeyModifiers==ModifierKeyStateProvider.ModifierKeyState){Interaction.ExecuteActions(AssociatedObject,Actions,e);}}}
I had 2 problems with
ButtonClickEventTriggerBehavior
.It seems that only modifier keys get tracked for events that reach the control:
Avalonia.Xaml.Behaviors/src/Avalonia.Xaml.Interactions.Custom/ButtonClickEventTriggerBehavior.cs
Lines 36 to 37 in 5d73e78
Key Events that happened outside of the control / before the control was created are not respected.
I might be wrong about 1.
My working modified version of
ButtonClickEventTriggerBehavior
is below, but I'm not really happy with the implementation as it involves setting event handlers on the top-level.Is there a better way to archive this?
Glue code in App code behind:
The text was updated successfully, but these errors were encountered: