From dddf88c93900309ed6b09df4c45a406ce7f0aee0 Mon Sep 17 00:00:00 2001 From: Tamilarasan Paranthaman <93904422+Tamilarasan-Paranthaman@users.noreply.github.com> Date: Thu, 22 May 2025 13:09:11 +0530 Subject: [PATCH 1/2] CollectionView drag changes on Mac --- .../Handlers/Items/iOS/ReorderableItemsViewController.cs | 6 ++++++ .../Handlers/Items2/iOS/ReorderableItemsViewController2.cs | 6 ++++++ 2 files changed, 12 insertions(+) diff --git a/src/Controls/src/Core/Handlers/Items/iOS/ReorderableItemsViewController.cs b/src/Controls/src/Core/Handlers/Items/iOS/ReorderableItemsViewController.cs index 63dc064fd595..26d81deb695d 100644 --- a/src/Controls/src/Core/Handlers/Items/iOS/ReorderableItemsViewController.cs +++ b/src/Controls/src/Core/Handlers/Items/iOS/ReorderableItemsViewController.cs @@ -162,6 +162,12 @@ public void UpdateCanReorderItems() if (_longPressGestureRecognizer == null) { _longPressGestureRecognizer = new UILongPressGestureRecognizer(HandleLongPress); +#if MACCATALYST + // On Mac Catalyst, we disable the default drag interaction and instead handle dragging using a long press gesture recognizer. + // Since a long press typically takes more time to trigger than the system's default drag interaction, + // we reduce the minimum press duration to 0.1 seconds to better match the previous behavior. + _longPressGestureRecognizer.MinimumPressDuration = 0.1; +#endif CollectionView.AddGestureRecognizer(_longPressGestureRecognizer); } } diff --git a/src/Controls/src/Core/Handlers/Items2/iOS/ReorderableItemsViewController2.cs b/src/Controls/src/Core/Handlers/Items2/iOS/ReorderableItemsViewController2.cs index 2114d4eecc35..07a129ae3d19 100644 --- a/src/Controls/src/Core/Handlers/Items2/iOS/ReorderableItemsViewController2.cs +++ b/src/Controls/src/Core/Handlers/Items2/iOS/ReorderableItemsViewController2.cs @@ -162,6 +162,12 @@ public void UpdateCanReorderItems() if (_longPressGestureRecognizer == null) { _longPressGestureRecognizer = new UILongPressGestureRecognizer(HandleLongPress); +#if MACCATALYST + // On Mac Catalyst, we disable the default drag interaction and instead handle dragging using a long press gesture recognizer. + // Since a long press typically takes more time to trigger than the system's default drag interaction, + // we reduce the minimum press duration to 0.1 seconds to better match the previous behavior. + _longPressGestureRecognizer.MinimumPressDuration = 0.1; +#endif CollectionView.AddGestureRecognizer(_longPressGestureRecognizer); } } From 4b09a5b523df845860c0e02c6cdb4ee432d1cb1a Mon Sep 17 00:00:00 2001 From: Tamilarasan Paranthaman <93904422+Tamilarasan-Paranthaman@users.noreply.github.com> Date: Fri, 23 May 2025 12:40:17 +0530 Subject: [PATCH 2/2] Mac drag changes --- .../Handlers/Items/iOS/ReorderableItemsViewController.cs | 6 +++++- .../Handlers/Items2/iOS/ReorderableItemsViewController2.cs | 6 +++++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/src/Controls/src/Core/Handlers/Items/iOS/ReorderableItemsViewController.cs b/src/Controls/src/Core/Handlers/Items/iOS/ReorderableItemsViewController.cs index 26d81deb695d..d70b9c92c8d9 100644 --- a/src/Controls/src/Core/Handlers/Items/iOS/ReorderableItemsViewController.cs +++ b/src/Controls/src/Core/Handlers/Items/iOS/ReorderableItemsViewController.cs @@ -14,6 +14,10 @@ public class ReorderableItemsViewController : GroupableItemsViewCont bool _disposed; UILongPressGestureRecognizer _longPressGestureRecognizer; +#if MACCATALYST + const double defaultMacCatalystPressDuration = 0.1; +#endif + public ReorderableItemsViewController(TItemsView reorderableItemsView, ItemsViewLayout layout) : base(reorderableItemsView, layout) { @@ -166,7 +170,7 @@ public void UpdateCanReorderItems() // On Mac Catalyst, we disable the default drag interaction and instead handle dragging using a long press gesture recognizer. // Since a long press typically takes more time to trigger than the system's default drag interaction, // we reduce the minimum press duration to 0.1 seconds to better match the previous behavior. - _longPressGestureRecognizer.MinimumPressDuration = 0.1; + _longPressGestureRecognizer.MinimumPressDuration = defaultMacCatalystPressDuration; #endif CollectionView.AddGestureRecognizer(_longPressGestureRecognizer); } diff --git a/src/Controls/src/Core/Handlers/Items2/iOS/ReorderableItemsViewController2.cs b/src/Controls/src/Core/Handlers/Items2/iOS/ReorderableItemsViewController2.cs index 07a129ae3d19..2cf389c6a485 100644 --- a/src/Controls/src/Core/Handlers/Items2/iOS/ReorderableItemsViewController2.cs +++ b/src/Controls/src/Core/Handlers/Items2/iOS/ReorderableItemsViewController2.cs @@ -14,6 +14,10 @@ public class ReorderableItemsViewController2 : GroupableItemsViewCon bool _disposed; UILongPressGestureRecognizer _longPressGestureRecognizer; +#if MACCATALYST + const double defaultMacCatalystPressDuration = 0.1; +#endif + public ReorderableItemsViewController2(TItemsView reorderableItemsView, UICollectionViewLayout layout) : base(reorderableItemsView, layout) { @@ -166,7 +170,7 @@ public void UpdateCanReorderItems() // On Mac Catalyst, we disable the default drag interaction and instead handle dragging using a long press gesture recognizer. // Since a long press typically takes more time to trigger than the system's default drag interaction, // we reduce the minimum press duration to 0.1 seconds to better match the previous behavior. - _longPressGestureRecognizer.MinimumPressDuration = 0.1; + _longPressGestureRecognizer.MinimumPressDuration = defaultMacCatalystPressDuration; #endif CollectionView.AddGestureRecognizer(_longPressGestureRecognizer); }