Skip to content

Commit

Permalink
Fix objects not selected on right-click
Browse files Browse the repository at this point in the history
- This is a regression from 78f1d34
- The workaround is to set the curesor to null when on Mac and right-clicking
- See #1099
  • Loading branch information
Phillipus committed Dec 5, 2024
1 parent 5526a98 commit 01ba8db
Showing 1 changed file with 14 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@

import org.eclipse.gef.tools.PanningSelectionTool;

import com.archimatetool.editor.utils.PlatformUtils;

/**
* Extend the PanningSelectionTool so that Panning occurs on middle mouse button
*
Expand All @@ -16,30 +18,32 @@ public class PanningSelectionExtendedTool extends PanningSelectionTool {

@Override
protected boolean handleButtonDown(int which) {
if(which == 2) {
if(which == 2) { // Middle mouse button
if(stateTransition(STATE_INITIAL, PAN)) {
refreshCursor();
}
which = 1;
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);
}

@Override
protected boolean handleButtonUp(int which) {
if(which == 2) {
which = 1;
if(which == 2) { // Middle mouse button
return super.handleButtonUp(1); // Set to left mouse
}

return super.handleButtonUp(which);
Expand Down

0 comments on commit 01ba8db

Please sign in to comment.