From a57bdbc25433775861b40e3a4c00136a7f9f50fd Mon Sep 17 00:00:00 2001 From: robloo Date: Tue, 25 Jan 2022 19:25:48 -0500 Subject: [PATCH] Implement secondary button span but disable it with commented reasons --- .../SplitButton/SplitButton.cs | 23 ++++++++++++++++--- .../Controls/SplitButton.xaml | 23 ++++++++++++------- 2 files changed, 35 insertions(+), 11 deletions(-) diff --git a/src/Avalonia.Controls/SplitButton/SplitButton.cs b/src/Avalonia.Controls/SplitButton/SplitButton.cs index efb7587960..ceff577eda 100644 --- a/src/Avalonia.Controls/SplitButton/SplitButton.cs +++ b/src/Avalonia.Controls/SplitButton/SplitButton.cs @@ -186,8 +186,24 @@ namespace Avalonia.Controls protected void UpdatePseudoClasses() { // Place the secondary button - // These are mutually exclusive PseudoClasses handled separately from SetExclusivePseudoClass(). - // They must be applied in addition to the others. + // + // In WinUI, the span of the secondary button is changed to full-width for touch-based + // devices in certain conditions. The full reasoning for this is unknown. Some theories + // include: + // + // My guess is that the design team at MS decided that it's a better experience + // for touch users to make them select from the drop down rather than the shortcut + // top level button, so touch basically just turns this into a drop down button. + // Whether that's ideal or not is going is a subjective opinion. + // + // For Avalonia, it may not always make sense to disable the primary button like that + // on touch-first platforms. Users and developers would normally expect a control to + // function the same on all platforms. Therefore, this functionality is disabled here + // but could be re-enabled in the future if more reasons become known. + // + // Finally, these are mutually exclusive PseudoClasses handled separately from + // SetExclusivePseudoClass(). They must be applied in addition to the others. + /* if (_lastPointerType == PointerType.Touch || _isKeyDown) { PseudoClasses.Set(pcSecondaryButtonSpan, true); @@ -198,9 +214,10 @@ namespace Avalonia.Controls PseudoClasses.Set(pcSecondaryButtonSpan, false); PseudoClasses.Set(pcSecondaryButtonRight, true); } + */ // Change the visual state - if (!IsEnabled) + if (!IsEffectivelyEnabled) { SetExclusivePseudoClass(pcDisabled); } diff --git a/src/Avalonia.Themes.Fluent/Controls/SplitButton.xaml b/src/Avalonia.Themes.Fluent/Controls/SplitButton.xaml index bd3996e399..fd1ab4d9b4 100644 --- a/src/Avalonia.Themes.Fluent/Controls/SplitButton.xaml +++ b/src/Avalonia.Themes.Fluent/Controls/SplitButton.xaml @@ -10,7 +10,7 @@ 32 - 32 + 32 - - + + --> +