From 3d5e535b6985ce77aa61fec476e0b545a6dd0f99 Mon Sep 17 00:00:00 2001 From: Arjen Hiemstra Date: Thu, 20 Apr 2017 17:53:05 +0200 Subject: [PATCH] Select the object underneath the cursor on context menu request Contributes to CURA-3609 --- cura/CuraApplication.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/cura/CuraApplication.py b/cura/CuraApplication.py index e7a6ac07c1..0ab3c1c1cf 100755 --- a/cura/CuraApplication.py +++ b/cura/CuraApplication.py @@ -219,6 +219,7 @@ class CuraApplication(QtApplication): self.getController().getScene().sceneChanged.connect(self.updatePlatformActivity) self.getController().toolOperationStopped.connect(self._onToolOperationStopped) + self.getController().contextMenuRequested.connect(self._onContextMenuRequested) Resources.addType(self.ResourceTypes.QmlFiles, "qml") Resources.addType(self.ResourceTypes.Firmware, "firmware") @@ -1332,3 +1333,10 @@ class CuraApplication(QtApplication): except Exception as e: Logger.log("e", "Could not check file %s: %s", file_url, e) return False + + def _onContextMenuRequested(self, x, y): + # Ensure we select the object if we request a context menu over an object without having a selection. + if not Selection.hasSelection(): + node = self.getController().getScene().findObject(self.getRenderer().getRenderPass("selection").getIdAtPosition(x, y)) + if node: + Selection.add(node)