def mousePressEvent(self, event: QMouseEvent):
if self.scene() is None:
return
cursor = self.cursor().shape()
has_shift_modifier = event.modifiers() == Qt.ShiftModifier
is_in_shift_mode = (has_shift_modifier and self.hold_shift_to_drag) \
or (not has_shift_modifier and not self.hold_shift_to_drag) \
and cursor != Qt.SplitHCursor and cursor != Qt.SplitVCursor
if event.buttons() == Qt.LeftButton and is_in_shift_mode:
self.setCursor(Qt.ClosedHandCursor)
self.grab_start = event.pos()
elif event.buttons() == Qt.LeftButton:
if self.is_pos_in_separea(self.mapToScene(event.pos())):
self.separation_area_moving = True
self.setCursor(Qt.SplitVCursor)
elif self.selection_area.is_empty or self.selection_area.selected_edge is None:
# Create new selection
self.mouse_press_pos = event.pos()
self.mouse_pos = event.pos()
scene_pos = self.mapToScene(self.mouse_press_pos)
self.__set_selection_area(x=scene_pos.x(), y=scene_pos.y(), w=0, h=0)
self.selection_area.finished = False
elif self.selection_area.selected_edge is not None:
self.selection_area.resizing = True
评论列表
文章目录