From 38da08cb4282ed5d4127aac04cefe4bee3ae5327 Mon Sep 17 00:00:00 2001
From: Phillipus
Date: Thu, 5 Dec 2024 10:54:37 +0000
Subject: [PATCH] Fix objects not selected on right-click
- This is a regression from 78f1d34723bed1d522f5c0be898542b5362026cc
- The workaround is to set the curesor to null when on Mac and right-clicking
- See https://github.com/archimatetool/archi/issues/1099
- And tody up the code
---
.../tools/PanningSelectionExtendedTool.java | 32 +++++++++++--------
1 file changed, 18 insertions(+), 14 deletions(-)
diff --git a/com.archimatetool.editor/src/com/archimatetool/editor/diagram/tools/PanningSelectionExtendedTool.java b/com.archimatetool.editor/src/com/archimatetool/editor/diagram/tools/PanningSelectionExtendedTool.java
index 87f4e1883..751b88e62 100644
--- a/com.archimatetool.editor/src/com/archimatetool/editor/diagram/tools/PanningSelectionExtendedTool.java
+++ b/com.archimatetool.editor/src/com/archimatetool/editor/diagram/tools/PanningSelectionExtendedTool.java
@@ -7,8 +7,10 @@
import org.eclipse.gef.tools.PanningSelectionTool;
+import com.archimatetool.editor.utils.PlatformUtils;
+
/**
- * Extend the PanningSelectionTool so that Panning occurs on middle mouse button
+ * Extend the PanningSelectionTool so that panning occurs on middle mouse button
*
* @author Phillip Beauvoir
*/
@@ -16,21 +18,22 @@ public class PanningSelectionExtendedTool extends PanningSelectionTool {
@Override
protected boolean handleButtonDown(int which) {
- if(which == 2) {
- if(stateTransition(STATE_INITIAL, PAN)) {
- refreshCursor();
- }
- which = 1;
+ // Middle mouse button down so set to panning state
+ if(which == 2 && stateTransition(STATE_INITIAL, PAN)) {
+ refreshCursor();
+ return super.handleButtonDown(1); // Set to left mouse
}
/*
- * A right-click on the canvas will show the plus cursor for the marquee selection tool.
- * On macOS Sonoma the current cursor persists onto the context menu.
- * This is a general problem with Sonoma, see https://github.com/eclipse-platform/eclipse.platform.swt/issues/773
- * As the right-click is only for showing the context menu we don't need to see this cursor when right-clicking at all, so trap this here.
+ * A right-click on the canvas will briefly show the plus cursor for the marquee selection tool before showing the context menu.
+ * On macOS Sonoma and greater this cursor persists while the context menu is shown.
+ * This is a general problem with Mac, see https://github.com/eclipse-platform/eclipse.platform.swt/issues/773
+ * As right-click is only used for showing the context menu we don't need to see this cursor when right-clicking at all, so trap this here.
*/
- if(which == 3) {
- return true;
+ if(PlatformUtils.isMac() && which == 3 || (which == 1 && getCurrentInput().isControlKeyDown())) {
+ boolean result = super.handleButtonDown(which);
+ setCursor(null);
+ return result;
}
return super.handleButtonDown(which);
@@ -38,8 +41,9 @@ protected boolean handleButtonDown(int which) {
@Override
protected boolean handleButtonUp(int which) {
- if(which == 2) {
- which = 1;
+ // Middle mouse button up and panning in progress
+ if(which == 2 && isInState(PAN_IN_PROGRESS)) {
+ return super.handleButtonUp(1); // Set to left mouse
}
return super.handleButtonUp(which);