Browse Source
Merge pull request #7252 from timunie/fix/ButtonSpinnerPointerWheel
Improve ButtonSpinner OnPointerWheel
pull/7270/head
Max Katz
5 years ago
committed by
GitHub
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with
6 additions and
3 deletions
-
src/Avalonia.Controls/ButtonSpinner.cs
-
src/Avalonia.Themes.Default/ButtonSpinner.xaml
-
src/Avalonia.Themes.Fluent/Controls/ButtonSpinner.xaml
|
|
|
@ -1,4 +1,4 @@ |
|
|
|
using System; |
|
|
|
using System; |
|
|
|
using Avalonia.Controls.Metadata; |
|
|
|
using Avalonia.Controls.Primitives; |
|
|
|
using Avalonia.Data; |
|
|
|
@ -196,13 +196,14 @@ namespace Avalonia.Controls |
|
|
|
protected override void OnPointerWheelChanged(PointerWheelEventArgs e) |
|
|
|
{ |
|
|
|
base.OnPointerWheelChanged(e); |
|
|
|
if (!e.Handled && AllowSpin) |
|
|
|
|
|
|
|
if (AllowSpin && IsKeyboardFocusWithin) |
|
|
|
{ |
|
|
|
if (e.Delta.Y != 0) |
|
|
|
{ |
|
|
|
var spinnerEventArgs = new SpinEventArgs(SpinEvent, (e.Delta.Y < 0) ? SpinDirection.Decrease : SpinDirection.Increase, true); |
|
|
|
OnSpin(spinnerEventArgs); |
|
|
|
e.Handled = spinnerEventArgs.Handled; |
|
|
|
e.Handled = true; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
@ -5,6 +5,7 @@ |
|
|
|
<Setter Property="BorderThickness" Value="{DynamicResource ThemeBorderThickness}"/> |
|
|
|
<Setter Property="HorizontalContentAlignment" Value="Stretch"/> |
|
|
|
<Setter Property="VerticalContentAlignment" Value="Center"/> |
|
|
|
<Setter Property="Focusable" Value="True"/> |
|
|
|
</Style> |
|
|
|
<Style Selector="ButtonSpinner /template/ RepeatButton"> |
|
|
|
<Setter Property="Background" Value="Transparent"/> |
|
|
|
|
|
|
|
@ -64,6 +64,7 @@ |
|
|
|
<Setter Property="FontSize" Value="{DynamicResource ControlContentThemeFontSize}" /> |
|
|
|
<Setter Property="HorizontalContentAlignment" Value="Stretch" /> |
|
|
|
<Setter Property="VerticalContentAlignment" Value="Center" /> |
|
|
|
<Setter Property="Focusable" Value="True"/> |
|
|
|
<Setter Property="Template"> |
|
|
|
<ControlTemplate> |
|
|
|
<DataValidationErrors> |
|
|
|
|