X-Git-Url: http://gitweb.fperrin.net/?p=GpsPrune.git;a=blobdiff_plain;f=tim%2Fprune%2Fgui%2Fmap%2FMapCanvas.java;fp=tim%2Fprune%2Fgui%2Fmap%2FMapCanvas.java;h=aa25dbcd939e39b96a6642f188b68665d4c74c4f;hp=801adbb0137e61575d7d00d5468a4e115425c867;hb=2d8cb72e84d5cc1089ce77baf1e34ea3ea2f8465;hpb=1a735a99408fd3b0c5ac4fe7b2fdbdbb23d38f40 diff --git a/tim/prune/gui/map/MapCanvas.java b/tim/prune/gui/map/MapCanvas.java index 801adbb..aa25dbc 100644 --- a/tim/prune/gui/map/MapCanvas.java +++ b/tim/prune/gui/map/MapCanvas.java @@ -1076,7 +1076,7 @@ public class MapCanvas extends JPanel implements MouseListener, MouseMotionListe { if (_track != null && _track.getNumPoints() > 0) { - // select point if it's a left-click + // select point if it's a left-click if (!inE.isMetaDown()) { if (inE.getClickCount() == 1) @@ -1269,9 +1269,27 @@ public class MapCanvas extends JPanel implements MouseListener, MouseMotionListe */ public void mouseDragged(MouseEvent inE) { - if (!inE.isMetaDown()) + // Note: One would expect inE.isMetaDown() to give information about whether this is a + // drag with the right mouse button or not - but since java 9 this is buggy, + // so we use the beautifully-named getModifiersEx() instead. + // And logically BUTTON3 refers to the secondary mouse button, not the tertiary one! + final boolean isRightDrag = (inE.getModifiersEx() & InputEvent.BUTTON3_DOWN_MASK) > 0; + if (isRightDrag) + { + // Right-click and drag - update rectangle + _drawMode = MODE_ZOOM_RECT; + if (_dragFromX == -1) { + _dragFromX = inE.getX(); + _dragFromY = inE.getY(); + } + _dragToX = inE.getX(); + _dragToY = inE.getY(); + repaint(); + } + else { - // Left mouse drag - either drag the point or pan the map + // Left mouse drag - decide whether to drag the point, drag the + // marking rectangle or pan the map if (_drawMode == MODE_DRAG_POINT || _drawMode == MODE_CREATE_MIDPOINT) { // move point @@ -1302,18 +1320,6 @@ public class MapCanvas extends JPanel implements MouseListener, MouseMotionListe _dragFromY = _dragToY = inE.getY(); } } - else - { - // Right-click and drag - update rectangle - _drawMode = MODE_ZOOM_RECT; - if (_dragFromX == -1) { - _dragFromX = inE.getX(); - _dragFromY = inE.getY(); - } - _dragToX = inE.getX(); - _dragToY = inE.getY(); - repaint(); - } } /**