Changeset 1939 in josm for trunk/src/org/openstreetmap/josm/gui/MapMover.java
- Timestamp:
- 2009-08-09T18:09:06+02:00 (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/gui/MapMover.java
r1722 r1939 1 1 // License: GPL. Copyright 2007 by Immanuel Scholz and others 2 2 package org.openstreetmap.josm.gui; 3 4 import static org.openstreetmap.josm.tools.I18n.tr; 3 5 4 6 import java.awt.Cursor; … … 15 17 import javax.swing.JComponent; 16 18 import javax.swing.JPanel; 19 20 import org.openstreetmap.josm.Main; 21 import org.openstreetmap.josm.data.coor.EastNorth; 22 import org.openstreetmap.josm.tools.PlatformHookOsx; 17 23 import org.openstreetmap.josm.tools.Shortcut; 18 import static org.openstreetmap.josm.tools.I18n.tr;19 20 import org.openstreetmap.josm.data.coor.EastNorth;21 24 22 25 /** … … 135 138 @Override public void mousePressed(MouseEvent e) { 136 139 int offMask = MouseEvent.BUTTON1_DOWN_MASK | MouseEvent.BUTTON2_DOWN_MASK; 137 if (e.getButton() == MouseEvent.BUTTON3 && (e.getModifiersEx() & offMask) == 0) 140 int macMouseMask = MouseEvent.CTRL_DOWN_MASK | MouseEvent.BUTTON1_DOWN_MASK; 141 if (e.getButton() == MouseEvent.BUTTON3 && (e.getModifiersEx() & offMask) == 0) { 138 142 startMovement(e); 143 } else if (isPlatformOsx() && e.getModifiersEx() == macMouseMask) { 144 startMovement(e); 145 } 139 146 } 140 147 … … 143 150 */ 144 151 @Override public void mouseReleased(MouseEvent e) { 145 if (e.getButton() == MouseEvent.BUTTON3) 152 if (e.getButton() == MouseEvent.BUTTON3) { 146 153 endMovement(); 154 } else if (isPlatformOsx() && e.getButton() == MouseEvent.BUTTON1) { 155 endMovement(); 156 } 147 157 } 148 158 … … 185 195 186 196 /** 187 * Does nothing. Only to satisfy MouseMotionListener 188 */ 189 public void mouseMoved(MouseEvent e) {} 197 * Emulates dragging on Mac OSX 198 */ 199 public void mouseMoved(MouseEvent e) { 200 if (!movementInPlace) 201 return; 202 // Mac OSX simulates with ctrl + mouse 1 the second mouse button hence no dragging events get fired. 203 // Is only the selected mouse button pressed? 204 if (isPlatformOsx()) { 205 if (e.getModifiersEx() == MouseEvent.CTRL_DOWN_MASK) { 206 if (mousePosMove == null) { 207 startMovement(e); 208 } 209 EastNorth center = nc.getCenter(); 210 EastNorth mouseCenter = nc.getEastNorth(e.getX(), e.getY()); 211 nc.zoomTo(new EastNorth(mousePosMove.east() + center.east() - mouseCenter.east(), mousePosMove.north() 212 + center.north() - mouseCenter.north())); 213 } else { 214 endMovement(); 215 } 216 } 217 } 218 219 /** 220 * Replies true if we are currently running on OSX 221 * 222 * @return true if we are currently running on OSX 223 */ 224 public static boolean isPlatformOsx() { 225 return Main.platform != null && Main.platform instanceof PlatformHookOsx; 226 } 227 190 228 }
Note:
See TracChangeset
for help on using the changeset viewer.