From ef53d8d216ea027759a055eee618c5b9339771e1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Krzysztof=20K=C5=82apyta?= <33362868+krystofair@users.noreply.github.com> Date: Sat, 13 Sep 2025 13:23:44 +0200 Subject: [PATCH] UserInteraction can be extended by shift. Introduced flag for keep state if shift was pressed on interaction ends. Use this for arrow adnotation operation. --- orangecanvas/document/interactions.py | 4 ++++ orangecanvas/document/schemeedit.py | 12 ++++++++++-- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/orangecanvas/document/interactions.py b/orangecanvas/document/interactions.py index 507c22d4..a94b42d6 100644 --- a/orangecanvas/document/interactions.py +++ b/orangecanvas/document/interactions.py @@ -116,6 +116,7 @@ def __init__(self, document, parent=None, deleteOnEnd=True): self.deleteOnEnd = deleteOnEnd self.cancelOnEsc = False + self.extendedOnShift = False self.__finished = False self.__canceled = False @@ -1415,6 +1416,9 @@ def mouseReleaseEvent(self, event): p1, p2 = map(self.arrow_item.mapFromScene, (p1, p2)) self.arrow_item.setLine(QLineF(p1, p2)) + if event.modifiers() & Qt.ShiftModifier: + self.extendedOnShift = True + self.end() return True else: diff --git a/orangecanvas/document/schemeedit.py b/orangecanvas/document/schemeedit.py index 5a2f60ba..91019d6b 100644 --- a/orangecanvas/document/schemeedit.py +++ b/orangecanvas/document/schemeedit.py @@ -1913,7 +1913,7 @@ def __toggleNewArrowAnnotation(self, checked): handler = self.__scene.user_interaction_handler if isinstance(handler, interactions.NewArrowAnnotation): # Cancel the interaction and restore the state - handler.ended.disconnect(action.toggle) + handler.ended.disconnect(self.__toggleNewArrowAction) handler.cancel(interactions.UserInteraction.UserCancelReason) log.info("Canceled new arrow annotation") @@ -1922,10 +1922,18 @@ def __toggleNewArrowAnnotation(self, checked): checked_action = self.__arrowColorActionGroup.checkedAction() handler.setColor(checked_action.data()) - handler.ended.connect(action.toggle) + handler.ended.connect(self.__toggleNewArrowAction) self._setUserInteractionHandler(handler) + def __toggleNewArrowAction(self): + handler = self.sender() + action = self.__newArrowAnnotationAction + action.toggle() # end current + if handler.extendedOnShift: + handler.extendedOnShift = False # clear shift flag + action.toggle() # start new + def __onFontSizeTriggered(self, action): # type: (QAction) -> None if not self.__newTextAnnotationAction.isChecked():