View Issue Details

IDProjectCategoryView StatusLast Update
0002374NoesisGUIC++ SDKpublic2022-07-11 11:10
Reportersatorp Assigned Tosfernandez  
PrioritynormalSeverityblockReproducibilityalways
Status resolvedResolutionfixed 
Product Version3.1.3 
Target Version3.1.6Fixed in Version3.1.6 
Summary0002374: Slider's thumb may fail to update its dragging state when mouse capture changed
DescriptionThe thumb's IsDragging state is not updated correctly when mouse capture has been ended by other means than releasing the mouse button. Mouse capture may end prematurely, e.g. in following cases:
- User presses Alt+Tab (in Windows) to switch to another application
- The slider's visibility changes (e.g. when UI state is updated while user was dragging the slider's thumb)
- When running in debugger and the execution breaks during the dragging process

The code in Thumb::OnMouseLeftButtonUp seems to assume that mouse is still captured, which is not true for cases above. This results in Thumb::StopDrag will never get called, and the thumb will behave incorrectly when dragged once again.
Steps To Reproduce1. Start Noesis Gallery sample, and open Basic Input > Slider tab
2. Drag any slider's thumb, and while doing so press Alt+Tab to switch to another application
3. Return to Gallery sample, and try moving the slider's thumb again
4. Result: The thumb will not move smoothly, and it's visual state is also incorrect (grayed)
TagsNo tags attached.
PlatformWindows

Activities

satorp

satorp

2022-07-09 12:47

reporter   ~0008014

We're currently having a blocking issue caused by this bug. It will be helpful if you could provide us a patch as a workaround in the mean time. Thank you.
sfernandez

sfernandez

2022-07-11 11:10

manager   ~0008015

Fixed in changeset 11482:

Index: Thumb.cpp
===================================================================
--- Thumb.cpp	(revision 11481)
+++ Thumb.cpp	(revision 11482)
@@ -42,10 +42,12 @@
         {
             ReleaseMouseCapture();
         }
+        ReleaseAllTouchCaptures();
+
         SetReadOnlyProperty<bool>(IsDraggingProperty, false);
-        
-        DragCompletedEventArgs args(this, true, mCurrentScreenPosition.x - mStartScreenPosition.x, 
-            mCurrentScreenPosition.y - mStartScreenPosition.y);
+
+        Point offset = mCurrentScreenPosition - mStartScreenPosition;
+        DragCompletedEventArgs args(this, true, offset.x, offset.y);
         RaiseEvent(args);
     }
 }
@@ -278,6 +280,15 @@
     data->RegisterEvent(DragCompletedEvent, "DragCompleted", RoutingStrategy_Bubble);
     data->RegisterEvent(DragDeltaEvent, "DragDelta", RoutingStrategy_Bubble);
     data->RegisterEvent(DragStartedEvent, "DragStarted", RoutingStrategy_Bubble);
+
+    auto OnLostCapture = [](BaseComponent* sender, const EventArgs&)
+    {
+        Thumb* thumb = (Thumb*)sender;
+        thumb->CancelDrag();
+    };
+
+    data->RegisterEventHandler(LostMouseCaptureEvent, OnLostCapture);
+    data->RegisterEventHandler(LostTouchCaptureEvent, OnLostCapture);
 }
 
 NS_END_COLD_REGION

Issue History

Date Modified Username Field Change
2022-07-09 12:42 satorp New Issue
2022-07-09 12:47 satorp Note Added: 0008014
2022-07-11 10:49 sfernandez Assigned To => sfernandez
2022-07-11 10:49 sfernandez Status new => assigned
2022-07-11 10:49 sfernandez Target Version => 3.1.6
2022-07-11 11:10 sfernandez Status assigned => resolved
2022-07-11 11:10 sfernandez Resolution open => fixed
2022-07-11 11:10 sfernandez Fixed in Version => 3.1.6
2022-07-11 11:10 sfernandez Note Added: 0008015