diff --git a/b_asic/GUI/drag_button.py b/b_asic/GUI/drag_button.py index 6d8b4ad77031fe94386d9205754ff51f3dabc26d..7506caa6533b0096facb6d522fbf4f3cd3475b23 100644 --- a/b_asic/GUI/drag_button.py +++ b/b_asic/GUI/drag_button.py @@ -28,8 +28,8 @@ class DragButton(QPushButton): def mousePressEvent(self, event): if event.button() == Qt.LeftButton: - self._mouse_press_pos = event.globalPos() - self._mouse_move_pos = event.globalPos() + self._mouse_press_pos = event.pos() + self._mouse_move_pos = event.pos() for signal in self._window.signalList: signal.update() @@ -58,23 +58,14 @@ class DragButton(QPushButton): def mouseMoveEvent(self, event): if event.buttons() == Qt.LeftButton: - cur_pos = self.mapToGlobal(self.pos()) - global_pos = event.globalPos() - if self._mouse_move_pos is None: - self._mouse_move_pos = global_pos - - diff = global_pos - self._mouse_move_pos - new_pos = self.mapFromGlobal(cur_pos + diff) - self.move(new_pos) - - self._mouse_move_pos = global_pos + self.move(self.mapToParent(event.pos() - self._mouse_press_pos)) self._window.update() super(DragButton, self).mouseMoveEvent(event) def mouseReleaseEvent(self, event): if self._mouse_press_pos is not None: - moved = event.globalPos() - self._mouse_press_pos + moved = event.pos() - self._mouse_press_pos if moved.manhattanLength() > 3: event.ignore() return