Changeset 16939 in osm for applications/viewer/jmapviewer/src/org/openstreetmap/gui/jmapviewer/DefaultMapController.java
- Timestamp:
- 2009-08-09T18:09:03+02:00 (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
applications/viewer/jmapviewer/src/org/openstreetmap/gui/jmapviewer/DefaultMapController.java
r14053 r16939 10 10 import java.awt.event.MouseWheelListener; 11 11 12 import org.openstreetmap.josm.Main; 13 import org.openstreetmap.josm.tools.PlatformHookOsx; 14 12 15 /** 13 16 * Default map controller which implements map moving by pressing the right … … 18 21 */ 19 22 public class DefaultMapController extends JMapController implements MouseListener, MouseMotionListener, 20 23 MouseWheelListener { 21 24 22 25 private static final int MOUSE_BUTTONS_MASK = MouseEvent.BUTTON3_DOWN_MASK | MouseEvent.BUTTON1_DOWN_MASK 23 26 | MouseEvent.BUTTON2_DOWN_MASK; 24 27 28 private static final int MAC_MOUSE_BUTTON3_MASK = MouseEvent.CTRL_DOWN_MASK | MouseEvent.BUTTON1_DOWN_MASK; 25 29 public DefaultMapController(JMapViewer map) { 26 30 super(map); … … 55 59 56 60 public void mouseClicked(MouseEvent e) { 57 if (doubleClickZoomEnabled && e.getClickCount() == 2 && e.getButton() == MouseEvent.BUTTON1) 61 if (doubleClickZoomEnabled && e.getClickCount() == 2 && e.getButton() == MouseEvent.BUTTON1) { 58 62 map.zoomIn(e.getPoint()); 63 } 59 64 } 60 65 61 66 public void mousePressed(MouseEvent e) { 62 if (e.getButton() == movementMouseButton) { 67 if (e.getButton() == movementMouseButton || isPlatformOsx() && e.getModifiersEx() == MAC_MOUSE_BUTTON3_MASK) { 63 68 lastDragPoint = null; 64 69 isMoving = true; … … 67 72 68 73 public void mouseReleased(MouseEvent e) { 69 if (e.getButton() == movementMouseButton) { 74 if (e.getButton() == movementMouseButton || isPlatformOsx() && e.getButton() == MouseEvent.BUTTON1) { 70 75 lastDragPoint = null; 71 76 isMoving = false; … … 74 79 75 80 public void mouseWheelMoved(MouseWheelEvent e) { 76 if (wheelZoomEnabled) 81 if (wheelZoomEnabled) { 77 82 map.setZoom(map.getZoom() - e.getWheelRotation(), e.getPoint()); 83 } 78 84 } 79 85 … … 146 152 147 153 public void mouseMoved(MouseEvent e) { 154 // Mac OSX simulates with ctrl + mouse 1 the second mouse button hence no dragging events get fired. 155 // 156 if (isPlatformOsx()) { 157 if (!movementEnabled || !isMoving) 158 return; 159 // Is only the selected mouse button pressed? 160 if (e.getModifiersEx() == MouseEvent.CTRL_DOWN_MASK) { 161 Point p = e.getPoint(); 162 if (lastDragPoint != null) { 163 int diffx = lastDragPoint.x - p.x; 164 int diffy = lastDragPoint.y - p.y; 165 map.moveMap(diffx, diffy); 166 } 167 lastDragPoint = p; 168 } 169 170 } 171 172 } 173 174 /** 175 * Replies true if we are currently running on OSX 176 * 177 * @return true if we are currently running on OSX 178 */ 179 public static boolean isPlatformOsx() { 180 return Main.platform != null && Main.platform instanceof PlatformHookOsx; 148 181 } 149 182
Note:
See TracChangeset
for help on using the changeset viewer.