def __startDrag( self, qObject, qEvent, forKeyPress = False ) : if self.__lastButtonPressWidget is None : return False if qEvent.buttons() == QtCore.Qt.NoButton : # sometimes Qt can fail to give us a mouse button release event # for the widget that received the mouse button press - in particular # this appears to happen when a context menu is raised in the press # event. this can mean we end up here, with a __lastButtonPressWidget # we don't want, attempting to start a drag when no buttons are down. # so we fix that. self.__lastButtonPressWidget = None return False sourceWidget = self.__lastButtonPressWidget() if sourceWidget is None : # the widget died return False threshold = 3 if not forKeyPress else 0 if ( self.__lastButtonPressEvent.line.p0 - self.__widgetSpaceLine( qEvent, sourceWidget ).p0 ).length() < threshold : return False if sourceWidget._dragBeginSignal is None : return False dragDropEvent = GafferUI.DragDropEvent( Widget._buttons( qEvent.button() ), Widget._buttons( qEvent.buttons() ), self.__lastButtonPressEvent.line, Widget._modifiers( qEvent.modifiers() ), ) dragDropEvent.sourceWidget = sourceWidget dragDropEvent.destinationWidget = None dragDropEvent.__startedByKeyPress = forKeyPress dragData = sourceWidget._dragBeginSignal( sourceWidget, dragDropEvent ) if dragData is not None : dragDropEvent.data = dragData self.__lastButtonPressWidget = None self.__lastButtonPressEvent = None self.__dragDropEvent = dragDropEvent self.__updateDrag( qObject, qEvent ) return True