Ticket #22065: 22065.3.patch

File 22065.3.patch, 14.5 KB (added by taylor.smock, 3 years ago)

Fix no-help lasso

  • src/org/openstreetmap/josm/actions/mapmode/MapMode.java

    diff --git a/src/org/openstreetmap/josm/actions/mapmode/MapMode.java b/src/org/openstreetmap/josm/actions/mapmode/MapMode.java
    index 3ad0d71e27..22ac881173 100644
    a b import org.openstreetmap.josm.spi.preferences.PreferenceChangeEvent;  
    2020import org.openstreetmap.josm.spi.preferences.PreferenceChangedListener;
    2121import org.openstreetmap.josm.tools.ImageProvider;
    2222import org.openstreetmap.josm.tools.Logging;
     23import org.openstreetmap.josm.tools.PlatformHook;
     24import org.openstreetmap.josm.tools.PlatformManager;
    2325import org.openstreetmap.josm.tools.Shortcut;
    2426
    2527/**
    public abstract class MapMode extends JosmAction implements MouseListener, Mouse  
    3335    protected boolean ctrl;
    3436    protected boolean alt;
    3537    protected boolean shift;
     38    /**
     39     * {@code true} if the meta key was pressed (the "Windows" key or the Mac "Command" key)
     40     * @since xxx
     41     */
     42    protected boolean meta;
     43    /**
     44     * {@code true} if the platform specific menu key was pressed ("ctrl" on Linux/Windows, "cmd" on Mac)
     45     * @see PlatformHook#getMenuShortcutKeyMaskEx()
     46     * @since xxx
     47     */
     48    protected boolean platformMenuShortcutKeyMask;
    3649
    3750    /**
    3851     * Constructor for mapmodes without a menu
    public abstract class MapMode extends JosmAction implements MouseListener, Mouse  
    154167    }
    155168
    156169    /**
    157      * Update internal ctrl, alt, shift mask from given extended modifiers mask.
     170     * Update internal ctrl, alt, shift, meta mask from given extended modifiers mask.
    158171     * @param modifiers event extended modifiers mask
    159172     * @since 12517
    160173     */
    public abstract class MapMode extends JosmAction implements MouseListener, Mouse  
    162175        ctrl = (modifiers & InputEvent.CTRL_DOWN_MASK) != 0;
    163176        alt = (modifiers & (InputEvent.ALT_DOWN_MASK | InputEvent.ALT_GRAPH_DOWN_MASK)) != 0;
    164177        shift = (modifiers & InputEvent.SHIFT_DOWN_MASK) != 0;
     178        meta = (modifiers & InputEvent.META_DOWN_MASK) != 0;
     179        platformMenuShortcutKeyMask = (modifiers & PlatformManager.getPlatform().getMenuShortcutKeyMaskEx()) != 0;
    165180    }
    166181
    167182    /**
  • src/org/openstreetmap/josm/actions/mapmode/SelectAction.java

    diff --git a/src/org/openstreetmap/josm/actions/mapmode/SelectAction.java b/src/org/openstreetmap/josm/actions/mapmode/SelectAction.java
    index 6983b3d585..97a7faa2f6 100644
    a b package org.openstreetmap.josm.actions.mapmode;  
    33
    44import static org.openstreetmap.josm.gui.help.HelpUtil.ht;
    55import static org.openstreetmap.josm.tools.I18n.tr;
     6import static org.openstreetmap.josm.tools.I18n.trc;
    67import static org.openstreetmap.josm.tools.I18n.trn;
    78
    89import java.awt.Cursor;
    910import java.awt.Point;
    1011import java.awt.Rectangle;
     12import java.awt.event.InputEvent;
    1113import java.awt.event.KeyEvent;
    1214import java.awt.event.MouseEvent;
    1315import java.awt.geom.Point2D;
    public class SelectAction extends MapMode implements ModifierExListener, KeyPres  
    287289            return repaintIfRequired(newHighlight);
    288290
    289291        // CTRL toggles selection, but if while dragging CTRL means merge
    290         final boolean isToggleMode = ctrl && !dragInProgress();
     292        final boolean isToggleMode = platformMenuShortcutKeyMask && !dragInProgress();
    291293        if (c.isPresent() && (isToggleMode || !c.get().isSelected())) {
    292294            // only highlight primitives that will change the selection
    293295            // when clicked. I.e. don't highlight selected elements unless
    public class SelectAction extends MapMode implements ModifierExListener, KeyPres  
    317319            if (dragInProgress()) {
    318320                // only consider merge if ctrl is pressed and there are nodes in
    319321                // the selection that could be merged
    320                 if (!ctrl || getLayerManager().getEditDataSet().getSelectedNodes().isEmpty()) {
     322                if (!platformMenuShortcutKeyMask || getLayerManager().getEditDataSet().getSelectedNodes().isEmpty()) {
    321323                    c = "move";
    322324                    break;
    323325                }
    public class SelectAction extends MapMode implements ModifierExListener, KeyPres  
    332334            c = (osm instanceof Way) ? "way" : c;
    333335            if (shift) {
    334336                c += "_add";
    335             } else if (ctrl) {
     337            } else if (platformMenuShortcutKeyMask) {
    336338                c += osm == null || osm.isSelected() ? "_rm" : "_add";
    337339            }
    338340            break;
    public class SelectAction extends MapMode implements ModifierExListener, KeyPres  
    346348            if (lassoMode) {
    347349                c = "lasso";
    348350            } else {
    349                 c = "rect" + (shift ? "_add" : (ctrl && !PlatformManager.isPlatformOsx() ? "_rm" : ""));
     351                if (shift) {
     352                    c = "rect_add";
     353                } else if (platformMenuShortcutKeyMask) {
     354                    c = "rect_rm";
     355                } else {
     356                    c = "rect";
     357                }
    350358            }
    351359            break;
    352360        }
    public class SelectAction extends MapMode implements ModifierExListener, KeyPres  
    408416
    409417        // We don't want to change to draw tool if the user tries to (de)select
    410418        // stuff but accidentally clicks in an empty area when selection is empty
    411         cancelDrawMode = shift || ctrl;
     419        cancelDrawMode = shift || platformMenuShortcutKeyMask;
    412420        didMouseDrag = false;
    413421        initialMoveThresholdExceeded = false;
    414422        mouseDownTime = System.currentTimeMillis();
    public class SelectAction extends MapMode implements ModifierExListener, KeyPres  
    513521        if (mode == Mode.MOVE) {
    514522            // If ctrl is pressed we are in merge mode. Look for a nearby node,
    515523            // highlight it and adjust the cursor accordingly.
    516             final boolean canMerge = ctrl && !getLayerManager().getEditDataSet().getSelectedNodes().isEmpty();
     524            final boolean canMerge = platformMenuShortcutKeyMask && !getLayerManager().getEditDataSet().getSelectedNodes().isEmpty();
    517525            final OsmPrimitive p = canMerge ? findNodeToMergeTo(e.getPoint()) : null;
    518526            boolean needsRepaint = removeHighlighting();
    519527            if (p != null) {
    public class SelectAction extends MapMode implements ModifierExListener, KeyPres  
    669677     */
    670678    private void determineMapMode(boolean hasSelectionNearby) {
    671679        if (getLayerManager().getEditDataSet() != null) {
    672             if (shift && ctrl) {
     680            if (shift && platformMenuShortcutKeyMask) {
    673681                mode = Mode.ROTATE;
    674             } else if (alt && ctrl) {
     682            } else if (alt && platformMenuShortcutKeyMask) {
    675683                mode = Mode.SCALE;
    676684            } else if (hasSelectionNearby || dragInProgress()) {
    677685                mode = Mode.MOVE;
    public class SelectAction extends MapMode implements ModifierExListener, KeyPres  
    860868        } else {
    861869            // if small number of elements were moved,
    862870            updateKeyModifiers(e);
    863             if (ctrl) mergePrims(e.getPoint());
     871            if (platformMenuShortcutKeyMask) mergePrims(e.getPoint());
    864872        }
    865873    }
    866874
    public class SelectAction extends MapMode implements ModifierExListener, KeyPres  
    978986        // Virtual Ways: if non-empty the cursor is above a virtual node. So don't highlight
    979987        // anything if about to drag the virtual node (i.e. !released) but continue if the
    980988        // cursor is only released above a virtual node by accident (i.e. released). See #7018
    981         if (ds == null || (shift && ctrl) || (ctrl && !released) || (virtualManager.hasVirtualWaysToBeConstructed() && !released))
     989        if (ds == null || (shift && platformMenuShortcutKeyMask) || (platformMenuShortcutKeyMask && !released)
     990                || (virtualManager.hasVirtualWaysToBeConstructed() && !released))
    982991            return;
    983992
    984993        if (!released) {
    public class SelectAction extends MapMode implements ModifierExListener, KeyPres  
    988997            shift |= ds.getSelected().containsAll(prims);
    989998        }
    990999
    991         if (ctrl) {
     1000        if (platformMenuShortcutKeyMask) {
    9921001            // Ctrl on an item toggles its selection status,
    9931002            // but Ctrl on an *area* just clears those items
    9941003            // out of the selection.
    public class SelectAction extends MapMode implements ModifierExListener, KeyPres  
    10171026
    10181027    @Override
    10191028    public String getModeHelpText() {
     1029        // There needs to be a better way
     1030        final String menuKey;
     1031        switch (PlatformManager.getPlatform().getMenuShortcutKeyMaskEx()) {
     1032        case InputEvent.CTRL_DOWN_MASK:
     1033            menuKey = trc("SelectAction help", "Ctrl");
     1034            break;
     1035        case InputEvent.META_DOWN_MASK:
     1036            menuKey = trc("SelectAction help", "Meta");
     1037            break;
     1038        default:
     1039            throw new IllegalStateException("Unknown platform menu shortcut key for " + PlatformManager.getPlatform().getOSDescription());
     1040        }
     1041        final String type = this.lassoMode ? trc("SelectAction help", "lasso") : trc("SelectAction help", "rectangle");
    10201042        if (mouseDownButton == MouseEvent.BUTTON1 && mouseReleaseTime < mouseDownTime) {
    10211043            if (mode == Mode.SELECT)
    1022                 return tr("Release the mouse button to select the objects in the rectangle.");
     1044                return tr("Release the mouse button to select the objects in the {0}.", type);
    10231045            else if (mode == Mode.MOVE && (System.currentTimeMillis() - mouseDownTime >= initialMoveDelay)) {
    10241046                final DataSet ds = getLayerManager().getEditDataSet();
    10251047                final boolean canMerge = ds != null && !ds.getSelectedNodes().isEmpty();
    1026                 final String mergeHelp = canMerge ? (' ' + tr("Ctrl to merge with nearest node.")) : "";
     1048                final String mergeHelp = canMerge ? (' ' + tr("{0} to merge with nearest node.", menuKey)) : "";
    10271049                return tr("Release the mouse button to stop moving.") + mergeHelp;
    10281050            } else if (mode == Mode.ROTATE)
    10291051                return tr("Release the mouse button to stop rotating.");
    10301052            else if (mode == Mode.SCALE)
    10311053                return tr("Release the mouse button to stop scaling.");
    10321054        }
    1033         return tr("Move objects by dragging; Shift to add to selection (Ctrl to toggle); Shift-Ctrl to rotate selected; " +
    1034                   "Alt-Ctrl to scale selected; or change selection");
     1055        return tr("Move objects by dragging; Shift to add to selection ({0} to toggle); Shift-{0} to rotate selected; " +
     1056                "Alt-{0} to scale selected; or change selection", menuKey);
    10351057    }
    10361058
    10371059    @Override
    public class SelectAction extends MapMode implements ModifierExListener, KeyPres  
    11061128                        // special case:  for cycle groups of 2, we can toggle to the
    11071129                        // true nearest primitive on mousePressed right away
    11081130                        if (cycleList.size() == 2 && !waitForMouseUpParameter) {
    1109                             if (!(osm.equals(old) || osm.isNew() || ctrl)) {
     1131                            if (!(osm.equals(old) || osm.isNew() || platformMenuShortcutKeyMask)) {
    11101132                                cyclePrims = false;
    11111133                                osm = old;
    11121134                            } // else defer toggling to mouseRelease time in those cases:
    public class SelectAction extends MapMode implements ModifierExListener, KeyPres  
    11541176                    if (nxt.isSelected()) {
    11551177                        foundInDS = nxt;
    11561178                        // first selected primitive in cycleList is found
    1157                         if (cyclePrims || ctrl) {
     1179                        if (cyclePrims || platformMenuShortcutKeyMask) {
    11581180                            ds.clearSelection(foundInDS); // deselect it
    11591181                            nxt = i.hasNext() ? i.next() : first;
    11601182                            // return next one in cycle list (last->first)
    public class SelectAction extends MapMode implements ModifierExListener, KeyPres  
    11651187            }
    11661188
    11671189            // if "no-alt-cycling" is enabled, Ctrl-Click arrives here.
    1168             if (ctrl) {
     1190            if (platformMenuShortcutKeyMask) {
    11691191                // a member of cycleList was found in the current dataset selection
    11701192                if (foundInDS != null) {
    11711193                    // mouse was moved to a different selection group w/ a previous sel
  • src/org/openstreetmap/josm/actions/mapmode/SelectLassoAction.java

    diff --git a/src/org/openstreetmap/josm/actions/mapmode/SelectLassoAction.java b/src/org/openstreetmap/josm/actions/mapmode/SelectLassoAction.java
    index d37a850842..df615bbcde 100644
    a b public class SelectLassoAction extends MapMode {  
    5454    public boolean layerIsSupported(Layer l) {
    5555        return MainApplication.getMap().mapModeSelect.layerIsSupported(l);
    5656    }
     57
     58    @Override
     59    public String getModeHelpText() {
     60        return MainApplication.getMap().mapModeSelect.getModeHelpText();
     61    }
    5762}
  • src/org/openstreetmap/josm/gui/SelectionManager.java

    diff --git a/src/org/openstreetmap/josm/gui/SelectionManager.java b/src/org/openstreetmap/josm/gui/SelectionManager.java
    index 602f4491f9..0f9e4a0e92 100644
    a b import org.openstreetmap.josm.data.osm.Way;  
    2626import org.openstreetmap.josm.data.osm.visitor.paint.PaintColors;
    2727import org.openstreetmap.josm.gui.layer.AbstractMapViewPaintable;
    2828import org.openstreetmap.josm.tools.ColorHelper;
     29import org.openstreetmap.josm.tools.PlatformManager;
    2930
    3031/**
    3132 * Manages the selection of a rectangle or a lasso loop. Listening to left and right mouse button
    public class SelectionManager implements MouseListener, MouseMotionListener, Pro  
    185186        if (e.getButton() == MouseEvent.BUTTON1 && e.getClickCount() > 1 && MainApplication.getLayerManager().getActiveDataSet() != null) {
    186187            SelectByInternalPointAction.performSelection(MainApplication.getMap().mapView.getEastNorth(e.getX(), e.getY()),
    187188                    (e.getModifiersEx() & MouseEvent.SHIFT_DOWN_MASK) != 0,
    188                     (e.getModifiersEx() & MouseEvent.CTRL_DOWN_MASK) != 0);
     189                    (e.getModifiersEx() & PlatformManager.getPlatform().getMenuShortcutKeyMaskEx()) != 0);
    189190        } else if (e.getButton() == MouseEvent.BUTTON1) {
    190191            mousePosStart = mousePos = e.getPoint();
    191192