Skip to content

Commit 2146b92

Browse files
Add guard around WinUI 3 ProtectedCursor property for Uno
1 parent e0d3091 commit 2146b92

File tree

3 files changed

+8
-4
lines changed

3 files changed

+8
-4
lines changed

labs/SizerBase/src/SizerBase.Properties.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,9 @@ private static void OnOrientationPropertyChanged(DependencyObject d, DependencyP
113113
return;
114114
}
115115

116-
#if WINAPPSDK
116+
// TODO: [UNO] Only supported on certain platforms
117+
// See ProtectedCursor here: https://github.com/unoplatform/uno/blob/3fe3862b270b99dbec4d830b547942af61b1a1d9/src/Uno.UI/UI/Xaml/UIElement.cs#L1015-L1023
118+
#if WINAPPSDK && !HAS_UNO
117119
// Need to wait until we're at least applying template step of loading before setting Cursor
118120
// See https://github.com/microsoft/microsoft-ui-xaml/issues/7062
119121
if (gripper._applyingTemplate &&

labs/SizerBase/src/SizerBase.cs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,8 @@ protected override AutomationPeer OnCreateAutomationPeer()
9292
return new SizerAutomationPeer(this);
9393
}
9494

95-
#if WINAPPSDK
95+
// On Uno the ProtectedCursor isn't supported yet, so we don't need this value.
96+
#if WINAPPSDK && !HAS_UNO
9697
// Used to track when we're in the OnApplyTemplateStep to change ProtectedCursor value.
9798
private bool _applyingTemplate = false;
9899
#endif
@@ -124,7 +125,7 @@ protected override void OnApplyTemplate()
124125

125126
// Trigger initial state transition based on if we're Enabled or not currently.
126127
SizerBase_IsEnabledChanged(this, null!);
127-
#if WINAPPSDK
128+
#if WINAPPSDK && !HAS_UNO
128129
// On WinAppSDK, we'll trigger this to setup the initial ProtectedCursor value.
129130
_applyingTemplate = true;
130131
#endif

labs/SizerBase/src/Toolkit/FrameworkElementExtensions.Mouse.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,8 @@ private static void CursorChanged(DependencyObject d, DependencyPropertyChangedE
8585
#if !WINAPPSDK
8686
private static void Element_PointerEntered(object sender, PointerRoutedEventArgs e)
8787
{
88-
// TODO [UNO] Only supported on certain platforms
88+
// TODO: [UNO] Only supported on certain platforms
89+
// See PointerCursor here: https://github.com/unoplatform/uno/blob/3fe3862b270b99dbec4d830b547942af61b1a1d9/src/Uno.UWP/UI/Core/CoreWindow.cs#L71-L77
8990
#if __NETFX_CORE__ || __WASM__ || __MACOS__ || __SKIA__
9091
CoreCursorType cursor = GetCursor((FrameworkElement)sender);
9192
Window.Current.CoreWindow.PointerCursor = _cursors[cursor];

0 commit comments

Comments
 (0)