Explorar o código

Change cursor on mouse release too

Michael Pitidis %!s(int64=13) %!d(string=hai) anos
pai
achega
0c461927e8
Modificáronse 1 ficheiros con 3 adicións e 2 borrados
  1. 3 2
      canvas.py

+ 3 - 2
canvas.py

@@ -11,8 +11,6 @@ from shape import Shape
 #   since performance on big images is a problem...
 # - [maybe] Highlight source vertex when "attracting" line.
 # - [maybe] Find optimal epsilon value.
-# - [maybe] Add cursor stack so that releasing the mouse after moving
-#   pops the previous, grab cursor.
 
 CURSOR_DEFAULT = Qt.ArrowCursor
 CURSOR_DRAW    = Qt.CrossCursor
@@ -154,11 +152,14 @@ class Canvas(QWidget):
         pos = self.transformPos(ev.posF())
         if ev.button() == Qt.RightButton:
             menu = self.menus[bool(self.selectedShapeCopy)]
+            self.restoreCursor()
             if not menu.exec_(self.mapToGlobal(ev.pos()))\
                and self.selectedShapeCopy:
                 # Cancel the move by deleting the shadow copy.
                 self.selectedShapeCopy = None
                 self.repaint()
+        elif ev.button() == Qt.LeftButton and self.selectedShape:
+            self.overrideCursor(CURSOR_GRAB)
 
     def endMove(self, copy=False):
         assert self.selectedShape and self.selectedShapeCopy