Fix exception on right click, showing context menu.
authorEdouard Tisserant <edouard.tisserant@gmail.com>
Wed, 24 Jan 2024 10:41:09 +0100
changeset 3894 25e9b557f1b8
parent 3887 2df45e4bd500
child 3895 b8f301b75567
Fix exception on right click, showing context menu.
editors/Viewer.py
--- a/editors/Viewer.py	Mon Jan 22 21:30:23 2024 +0100
+++ b/editors/Viewer.py	Wed Jan 24 10:41:09 2024 +0100
@@ -2153,7 +2153,8 @@
         event.Skip()
 
     def OnViewerRightDown(self, event):
-        self.Editor.CaptureMouse()
+        if not self.Editor.HasCapture():
+            self.Editor.CaptureMouse()
         if self.Mode == MODE_SELECTION:
             element = self.FindElement(event)
             if self.SelectedElement is not None and self.SelectedElement != element:
@@ -2173,6 +2174,8 @@
         self.rubberBand.Reset()
         self.rubberBand.OnLeftDown(event, dc, self.Scaling)
         self.rubberBand.OnLeftUp(event, dc, self.Scaling)
+        if self.Editor.HasCapture():
+            self.Editor.ReleaseMouse()
         if self.SelectedElement is not None:
             if self.Debug:
                 Graphic_Element.OnRightUp(self.SelectedElement, event, self.GetLogicalDC(), self.Scaling)