Changeset 29258 in osm for applications/editors


Ignore:
Timestamp:
2013-02-18T17:22:13+01:00 (12 years ago)
Author:
akks
Message:

'JOSM/touchscreenhelper: Added T shortcut, hold T to activate temporarily'

Location:
applications/editors/josm/plugins/touchscreenhelper
Files:
2 added
2 edited

Legend:

Unmodified
Added
Removed
  • applications/editors/josm/plugins/touchscreenhelper/build.xml

    r27354 r29258  
    3030<project name="touchscreenhelper" default="dist" basedir=".">
    3131    <!-- enter the SVN commit message -->
    32     <property name="commit.message" value="Commit message"/>
     32    <property name="commit.message" value="JOSM/touchscreenhelper: Added T shortcut, hold T to activate temporarily"/>
    3333    <!-- enter the *lowest* JOSM version this plugin is currently compatible with -->
    3434    <property name="plugin.main.version" value="4394"/>
     
    3737    <property name="plugin.src.dir" value="src"/>
    3838    <property name="plugin.dist.dir" value="../../dist"/>
    39     <property name="ant.build.javac.target" value="1.5"/>
     39    <property name="ant.build.javac.target" value="1.6"/>
    4040    <property name="plugin.dist.dir" value="../../dist"/>
    4141    <property name="plugin.jar" value="${plugin.dist.dir}/${ant.project.name}.jar"/>
  • applications/editors/josm/plugins/touchscreenhelper/src/touchscreenhelper/BrowseAction.java

    r23193 r29258  
    44
    55import java.awt.Cursor;
     6import java.awt.event.KeyEvent;
    67import java.awt.event.MouseEvent;
    78import java.awt.event.MouseListener;
     
    1213import org.openstreetmap.josm.gui.MapFrame;
    1314import org.openstreetmap.josm.data.coor.EastNorth;
     15import org.openstreetmap.josm.tools.Shortcut;
     16import uitils.TimedKeyReleaseListener;
    1417
    1518public class BrowseAction extends MapMode implements MouseListener,
    16     MouseMotionListener {
     19    MouseMotionListener, MapFrame.MapModeChangeListener {
     20
     21    private MapMode oldMapMode;
     22    private TimedKeyReleaseListener listener;
    1723
    1824    public BrowseAction(MapFrame mapFrame) {
    1925        super(tr("Browse"), "browse", tr("Browse map with left button"),
     26            Shortcut.registerShortcut("touchscreenhelper:browse", tr("Mode: {0}", tr("Browse map with left button")),
     27                KeyEvent.VK_T, Shortcut.DIRECT),
    2028            mapFrame, Cursor.getPredefinedCursor(Cursor.MOVE_CURSOR));
     29        MapFrame.addMapModeChangeListener(this);
    2130    }
    22 
     31   
     32    @Override
     33    public void mapModeChange(MapMode oldMapMode, MapMode newMapMode) {
     34        this.oldMapMode = oldMapMode;
     35    }
     36   
    2337    @Override public void enterMode() {
    2438        super.enterMode();
    25 
    2639        Main.map.mapView.addMouseListener(this);
    2740        Main.map.mapView.addMouseMotionListener(this);
     41
     42        listener = new TimedKeyReleaseListener() {
     43            @Override
     44            protected void doKeyReleaseEvent(KeyEvent evt) {
     45                if (evt.getKeyCode() == getShortcut().getKeyStroke().getKeyCode()) {
     46                    if (oldMapMode!=null && !(oldMapMode instanceof BrowseAction))
     47                    Main.map.selectMapMode(oldMapMode);
     48                }
     49            }
     50        };
    2851    }
    2952
     
    3356        Main.map.mapView.removeMouseListener(this);
    3457        Main.map.mapView.removeMouseMotionListener(this);
     58        listener.stop();
    3559    }
    3660
Note: See TracChangeset for help on using the changeset viewer.