Changeset 7218 in josm


Ignore:
Timestamp:
2014-06-06T10:30:46+02:00 (10 years ago)
Author:
akks
Message:

fix #3910: toggle lasso mode on repeating S key
can be turned of with mappaint.select.toggle-lasso-on-repeated-S

Location:
trunk/src/org/openstreetmap/josm
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/actions/mapmode/SelectAction.java

    r7217 r7218  
    4949import org.openstreetmap.josm.gui.layer.OsmDataLayer;
    5050import org.openstreetmap.josm.gui.util.GuiHelper;
     51import org.openstreetmap.josm.gui.util.KeyPressReleaseListener;
    5152import org.openstreetmap.josm.gui.util.ModifierListener;
    5253import org.openstreetmap.josm.tools.ImageProvider;
     
    6566 * feature "selection remove" is disabled on this platform.
    6667 */
    67 public class SelectAction extends MapMode implements ModifierListener, SelectionEnded {
     68public class SelectAction extends MapMode implements ModifierListener, KeyPressReleaseListener, SelectionEnded {
    6869    // "select" means the selection rectangle and "move" means either dragging
    6970    // or select if no mouse movement occurs (i.e. just clicking)
     
    102103
    103104    private boolean lassoMode = false;
     105    public boolean repeatedKeySwitchLassoOption;
    104106
    105107    // Cache previous mouse event (needed when only the modifier keys are
     
    182184        initialMoveDelay = Main.pref.getInteger("edit.initial-move-delay", 200);
    183185        initialMoveThreshold = Main.pref.getInteger("edit.initial-move-threshold", 5);
     186        repeatedKeySwitchLassoOption = Main.pref.getBoolean("mappaint.select.toggle-lasso-on-repeated-S", true);
    184187        cycleManager.init();
    185188        virtualManager.init();
    186189        // This is required to update the cursors when ctrl/shift/alt is pressed
    187190        Main.map.keyDetector.addModifierListener(this);
     191        Main.map.keyDetector.addKeyListener(this);
    188192    }
    189193
     
    196200        mv.setVirtualNodesEnabled(false);
    197201        Main.map.keyDetector.removeModifierListener(this);
     202        Main.map.keyDetector.removeKeyListener(this);
    198203        removeHighlighting();
    199204    }
     
    627632        updateKeyModifiers(e);
    628633        selectPrims(selectionManager.getSelectedObjects(alt), true, true);
     634    }
     635
     636    @Override
     637    public void doKeyPressed(KeyEvent e) {
     638        if (!Main.isDisplayingMapView() ||
     639                !repeatedKeySwitchLassoOption || !getShortcut().isEvent(e)) return;
     640        e.consume();
     641        if (!lassoMode) {
     642            Main.map.selectMapMode(Main.map.mapModeSelectLasso);
     643        } else {
     644            Main.map.selectMapMode(Main.map.mapModeSelect);
     645        }
     646    }
     647
     648    @Override
     649    public void doKeyReleased(KeyEvent e) {
    629650    }
    630651
  • trunk/src/org/openstreetmap/josm/gui/MapFrame.java

    r7217 r7218  
    135135    // Map modes
    136136    public final SelectAction mapModeSelect;
     137    public LassoModeAction mapModeSelectLasso;
     138
    137139    private final Map<Layer, MapMode> lastMapMode = new HashMap<>();
    138140    private final MapMode mapModeDraw;
     
    216218        // toolBarActions, map mode buttons
    217219        addMapMode(new IconToggleButton(mapModeSelect = new SelectAction(this)));
    218         addMapMode(new IconToggleButton(new LassoModeAction(), true));
     220        addMapMode(new IconToggleButton(mapModeSelectLasso = new LassoModeAction(), true));
    219221        addMapMode(new IconToggleButton(mapModeDraw = new DrawAction(this)));
    220222        addMapMode(new IconToggleButton(mapModeZoom = new ZoomAction(this)));
Note: See TracChangeset for help on using the changeset viewer.