From 2cbf22a67b578e9777401c98b3d61049daacde51 Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Tue, 26 Jul 2022 13:32:11 +0530 Subject: [PATCH] Image editor: Down allow initial mouse drag to create selection rect outside the image bounds --- src/calibre/gui2/tweak_book/editor/canvas.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/calibre/gui2/tweak_book/editor/canvas.py b/src/calibre/gui2/tweak_book/editor/canvas.py index 50d1e97f81..22747eb43b 100644 --- a/src/calibre/gui2/tweak_book/editor/canvas.py +++ b/src/calibre/gui2/tweak_book/editor/canvas.py @@ -534,7 +534,9 @@ class Canvas(QWidget): if ev.buttons() & Qt.MouseButton.LeftButton: if self.selection_state.last_press_point is not None and self.selection_state.current_mode is not None: if self.selection_state.current_mode == 'select': - self.selection_state.rect = QRectF(self.selection_state.last_press_point, pos).normalized() + r = QRectF(self.selection_state.last_press_point, pos).normalized() + r = r.intersected(self.target) + self.selection_state.rect = r changed = True elif self.selection_state.last_drag_pos is not None: self.selection_state.in_selection = True