Changeset 1939 in josm


Ignore:
Timestamp:
2009-08-09T18:09:06+02:00 (13 years ago)
Author:
Gubaer
Message:

applied #3165: patch by dmuecke: moving map on a macbook withouth external mouse

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/gui/MapMover.java

    r1722 r1939  
    11// License: GPL. Copyright 2007 by Immanuel Scholz and others
    22package org.openstreetmap.josm.gui;
     3
     4import static org.openstreetmap.josm.tools.I18n.tr;
    35
    46import java.awt.Cursor;
     
    1517import javax.swing.JComponent;
    1618import javax.swing.JPanel;
     19
     20import org.openstreetmap.josm.Main;
     21import org.openstreetmap.josm.data.coor.EastNorth;
     22import org.openstreetmap.josm.tools.PlatformHookOsx;
    1723import org.openstreetmap.josm.tools.Shortcut;
    18 import static org.openstreetmap.josm.tools.I18n.tr;
    19 
    20 import org.openstreetmap.josm.data.coor.EastNorth;
    2124
    2225/**
     
    135138    @Override public void mousePressed(MouseEvent e) {
    136139        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) {
    138142            startMovement(e);
     143        } else if (isPlatformOsx() && e.getModifiersEx() == macMouseMask) {
     144            startMovement(e);
     145        }
    139146    }
    140147
     
    143150     */
    144151    @Override public void mouseReleased(MouseEvent e) {
    145         if (e.getButton() == MouseEvent.BUTTON3)
     152        if (e.getButton() == MouseEvent.BUTTON3) {
    146153            endMovement();
     154        } else if (isPlatformOsx() && e.getButton() == MouseEvent.BUTTON1) {
     155            endMovement();
     156        }
    147157    }
    148158
     
    185195
    186196    /**
    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
    190228}
Note: See TracChangeset for help on using the changeset viewer.