meta zoom and two finger click fixes for mac

This commit is contained in:
bancika
2020-12-11 13:54:19 +01:00
parent a1072973d2
commit 011a06ec75
7 changed files with 29 additions and 7 deletions
@@ -340,7 +340,7 @@ public class MainFrame extends JFrame implements ISwingUI {
rightPanel.add(component);
break;
case SwingConstants.CENTER:
centerPanel.add(component, BorderLayout.CENTER);
centerPanel.add(component);
break;
default:
throw new BadPositionException();
@@ -139,10 +139,14 @@ public class CanvasPanel extends JComponent implements Autoscroll {
getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW)
.put(KeyStroke.getKeyStroke(KeyEvent.VK_ADD, KeyEvent.CTRL_DOWN_MASK), "zoomIn");
getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW)
.put(KeyStroke.getKeyStroke(KeyEvent.VK_PLUS, KeyEvent.CTRL_DOWN_MASK), "zoomIn");
getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW)
.put(KeyStroke.getKeyStroke(KeyEvent.VK_SUBTRACT, KeyEvent.CTRL_DOWN_MASK), "zoomOut");
getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW)
.put(KeyStroke.getKeyStroke(KeyEvent.VK_ADD, KeyEvent.META_DOWN_MASK), "zoomIn");
.put(KeyStroke.getKeyStroke(KeyEvent.VK_ADD, KeyEvent.META_DOWN_MASK), "zoomIn");
getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW)
.put(KeyStroke.getKeyStroke(KeyEvent.VK_PLUS, KeyEvent.META_DOWN_MASK), "zoomIn");
getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW)
.put(KeyStroke.getKeyStroke(KeyEvent.VK_EQUALS, KeyEvent.META_DOWN_MASK), "zoomIn");
getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW)
@@ -258,9 +258,12 @@ public class CanvasPlugin implements IPlugIn, ClipboardOwner {
public void mouseClicked(MouseEvent e) {
if (scrollPane.isMouseScrollMode() || e.getButton() == MouseEvent.BUTTON2)
return;
// do not pass isMetaDown on mac when button3 (two finger click) is pressed
boolean ctrlDown = Utils.isMac() ? (e.getButton() == MouseEvent.BUTTON3 ? false : e.isMetaDown()): e.isControlDown();
plugInPort.mouseClicked(e.getPoint(), e.getButton(),
Utils.isMac() ? e.isMetaDown() : e.isControlDown(), e.isShiftDown(), e.isAltDown(),
e.getClickCount());
ctrlDown, e.isShiftDown(), e.isAltDown(), e.getClickCount());
}
@Override
@@ -466,7 +469,7 @@ public class CanvasPlugin implements IPlugIn, ClipboardOwner {
}
public void zoom(int direction) {
Point mousePos = canvasPanel.getMousePosition(true);
Point mousePos = canvasPanel.getMousePosition(true);
// change zoom level
double oldZoom = plugInPort.getZoomLevel();
@@ -491,6 +494,9 @@ public class CanvasPlugin implements IPlugIn, ClipboardOwner {
JScrollBar horizontal = scrollPane.getHorizontalScrollBar();
JScrollBar vertical = scrollPane.getVerticalScrollBar();
if (mousePos == null)
mousePos = new Point((int)visibleRect.getCenterX(), (int)visibleRect.getCenterY());
if (selectionBounds == null) {
// center to cursor