diff --git a/src/org/openstreetmap/josm/actions/mapmode/MapMode.java b/src/org/openstreetmap/josm/actions/mapmode/MapMode.java
index 3ad0d71e27..62383c04c7 100644
a
|
b
|
import org.openstreetmap.josm.spi.preferences.PreferenceChangeEvent;
|
20 | 20 | import org.openstreetmap.josm.spi.preferences.PreferenceChangedListener; |
21 | 21 | import org.openstreetmap.josm.tools.ImageProvider; |
22 | 22 | import org.openstreetmap.josm.tools.Logging; |
| 23 | import org.openstreetmap.josm.tools.PlatformHook; |
| 24 | import org.openstreetmap.josm.tools.PlatformManager; |
23 | 25 | import org.openstreetmap.josm.tools.Shortcut; |
24 | 26 | |
25 | 27 | /** |
… |
… |
public abstract class MapMode extends JosmAction implements MouseListener, Mouse
|
33 | 35 | protected boolean ctrl; |
34 | 36 | protected boolean alt; |
35 | 37 | 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 | * @see PlatformHook#getMenuShortcutKeyMaskEx() |
| 45 | * @since xxx |
| 46 | */ |
| 47 | protected boolean platformMenuShortcutKeyMask; |
36 | 48 | |
37 | 49 | /** |
38 | 50 | * Constructor for mapmodes without a menu |
… |
… |
public abstract class MapMode extends JosmAction implements MouseListener, Mouse
|
154 | 166 | } |
155 | 167 | |
156 | 168 | /** |
157 | | * Update internal ctrl, alt, shift mask from given extended modifiers mask. |
| 169 | * Update internal ctrl, alt, shift, meta mask from given extended modifiers mask. |
158 | 170 | * @param modifiers event extended modifiers mask |
159 | 171 | * @since 12517 |
160 | 172 | */ |
… |
… |
public abstract class MapMode extends JosmAction implements MouseListener, Mouse
|
162 | 174 | ctrl = (modifiers & InputEvent.CTRL_DOWN_MASK) != 0; |
163 | 175 | alt = (modifiers & (InputEvent.ALT_DOWN_MASK | InputEvent.ALT_GRAPH_DOWN_MASK)) != 0; |
164 | 176 | shift = (modifiers & InputEvent.SHIFT_DOWN_MASK) != 0; |
| 177 | meta = (modifiers & InputEvent.META_DOWN_MASK) != 0; |
| 178 | platformMenuShortcutKeyMask = (modifiers & PlatformManager.getPlatform().getMenuShortcutKeyMaskEx()) != 0; |
165 | 179 | } |
166 | 180 | |
167 | 181 | /** |
diff --git a/src/org/openstreetmap/josm/actions/mapmode/SelectAction.java b/src/org/openstreetmap/josm/actions/mapmode/SelectAction.java
index 6983b3d585..7d50a22ba3 100644
a
|
b
|
public class SelectAction extends MapMode implements ModifierExListener, KeyPres
|
287 | 287 | return repaintIfRequired(newHighlight); |
288 | 288 | |
289 | 289 | // CTRL toggles selection, but if while dragging CTRL means merge |
290 | | final boolean isToggleMode = ctrl && !dragInProgress(); |
| 290 | final boolean isToggleMode = platformMenuShortcutKeyMask && !dragInProgress(); |
291 | 291 | if (c.isPresent() && (isToggleMode || !c.get().isSelected())) { |
292 | 292 | // only highlight primitives that will change the selection |
293 | 293 | // when clicked. I.e. don't highlight selected elements unless |
… |
… |
public class SelectAction extends MapMode implements ModifierExListener, KeyPres
|
317 | 317 | if (dragInProgress()) { |
318 | 318 | // only consider merge if ctrl is pressed and there are nodes in |
319 | 319 | // the selection that could be merged |
320 | | if (!ctrl || getLayerManager().getEditDataSet().getSelectedNodes().isEmpty()) { |
| 320 | if (!platformMenuShortcutKeyMask || getLayerManager().getEditDataSet().getSelectedNodes().isEmpty()) { |
321 | 321 | c = "move"; |
322 | 322 | break; |
323 | 323 | } |
… |
… |
public class SelectAction extends MapMode implements ModifierExListener, KeyPres
|
332 | 332 | c = (osm instanceof Way) ? "way" : c; |
333 | 333 | if (shift) { |
334 | 334 | c += "_add"; |
335 | | } else if (ctrl) { |
| 335 | } else if (platformMenuShortcutKeyMask) { |
336 | 336 | c += osm == null || osm.isSelected() ? "_rm" : "_add"; |
337 | 337 | } |
338 | 338 | break; |
… |
… |
public class SelectAction extends MapMode implements ModifierExListener, KeyPres
|
346 | 346 | if (lassoMode) { |
347 | 347 | c = "lasso"; |
348 | 348 | } else { |
349 | | c = "rect" + (shift ? "_add" : (ctrl && !PlatformManager.isPlatformOsx() ? "_rm" : "")); |
| 349 | if (shift) { |
| 350 | c = "rect_add"; |
| 351 | } else if (platformMenuShortcutKeyMask) { |
| 352 | c = "rect_rm"; |
| 353 | } else { |
| 354 | c = "rect"; |
| 355 | } |
350 | 356 | } |
351 | 357 | break; |
352 | 358 | } |
… |
… |
public class SelectAction extends MapMode implements ModifierExListener, KeyPres
|
408 | 414 | |
409 | 415 | // We don't want to change to draw tool if the user tries to (de)select |
410 | 416 | // stuff but accidentally clicks in an empty area when selection is empty |
411 | | cancelDrawMode = shift || ctrl; |
| 417 | cancelDrawMode = shift || platformMenuShortcutKeyMask; |
412 | 418 | didMouseDrag = false; |
413 | 419 | initialMoveThresholdExceeded = false; |
414 | 420 | mouseDownTime = System.currentTimeMillis(); |
… |
… |
public class SelectAction extends MapMode implements ModifierExListener, KeyPres
|
513 | 519 | if (mode == Mode.MOVE) { |
514 | 520 | // If ctrl is pressed we are in merge mode. Look for a nearby node, |
515 | 521 | // highlight it and adjust the cursor accordingly. |
516 | | final boolean canMerge = ctrl && !getLayerManager().getEditDataSet().getSelectedNodes().isEmpty(); |
| 522 | final boolean canMerge = platformMenuShortcutKeyMask && !getLayerManager().getEditDataSet().getSelectedNodes().isEmpty(); |
517 | 523 | final OsmPrimitive p = canMerge ? findNodeToMergeTo(e.getPoint()) : null; |
518 | 524 | boolean needsRepaint = removeHighlighting(); |
519 | 525 | if (p != null) { |
… |
… |
public class SelectAction extends MapMode implements ModifierExListener, KeyPres
|
669 | 675 | */ |
670 | 676 | private void determineMapMode(boolean hasSelectionNearby) { |
671 | 677 | if (getLayerManager().getEditDataSet() != null) { |
672 | | if (shift && ctrl) { |
| 678 | if (shift && platformMenuShortcutKeyMask) { |
673 | 679 | mode = Mode.ROTATE; |
674 | | } else if (alt && ctrl) { |
| 680 | } else if (alt && platformMenuShortcutKeyMask) { |
675 | 681 | mode = Mode.SCALE; |
676 | 682 | } else if (hasSelectionNearby || dragInProgress()) { |
677 | 683 | mode = Mode.MOVE; |
… |
… |
public class SelectAction extends MapMode implements ModifierExListener, KeyPres
|
860 | 866 | } else { |
861 | 867 | // if small number of elements were moved, |
862 | 868 | updateKeyModifiers(e); |
863 | | if (ctrl) mergePrims(e.getPoint()); |
| 869 | if (platformMenuShortcutKeyMask) mergePrims(e.getPoint()); |
864 | 870 | } |
865 | 871 | } |
866 | 872 | |
… |
… |
public class SelectAction extends MapMode implements ModifierExListener, KeyPres
|
978 | 984 | // Virtual Ways: if non-empty the cursor is above a virtual node. So don't highlight |
979 | 985 | // anything if about to drag the virtual node (i.e. !released) but continue if the |
980 | 986 | // 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)) |
| 987 | if (ds == null || (shift && platformMenuShortcutKeyMask) || (platformMenuShortcutKeyMask && !released) |
| 988 | || (virtualManager.hasVirtualWaysToBeConstructed() && !released)) |
982 | 989 | return; |
983 | 990 | |
984 | 991 | if (!released) { |
… |
… |
public class SelectAction extends MapMode implements ModifierExListener, KeyPres
|
988 | 995 | shift |= ds.getSelected().containsAll(prims); |
989 | 996 | } |
990 | 997 | |
991 | | if (ctrl) { |
| 998 | if (platformMenuShortcutKeyMask) { |
992 | 999 | // Ctrl on an item toggles its selection status, |
993 | 1000 | // but Ctrl on an *area* just clears those items |
994 | 1001 | // out of the selection. |
… |
… |
public class SelectAction extends MapMode implements ModifierExListener, KeyPres
|
1106 | 1113 | // special case: for cycle groups of 2, we can toggle to the |
1107 | 1114 | // true nearest primitive on mousePressed right away |
1108 | 1115 | if (cycleList.size() == 2 && !waitForMouseUpParameter) { |
1109 | | if (!(osm.equals(old) || osm.isNew() || ctrl)) { |
| 1116 | if (!(osm.equals(old) || osm.isNew() || platformMenuShortcutKeyMask)) { |
1110 | 1117 | cyclePrims = false; |
1111 | 1118 | osm = old; |
1112 | 1119 | } // else defer toggling to mouseRelease time in those cases: |
… |
… |
public class SelectAction extends MapMode implements ModifierExListener, KeyPres
|
1154 | 1161 | if (nxt.isSelected()) { |
1155 | 1162 | foundInDS = nxt; |
1156 | 1163 | // first selected primitive in cycleList is found |
1157 | | if (cyclePrims || ctrl) { |
| 1164 | if (cyclePrims || platformMenuShortcutKeyMask) { |
1158 | 1165 | ds.clearSelection(foundInDS); // deselect it |
1159 | 1166 | nxt = i.hasNext() ? i.next() : first; |
1160 | 1167 | // return next one in cycle list (last->first) |
… |
… |
public class SelectAction extends MapMode implements ModifierExListener, KeyPres
|
1165 | 1172 | } |
1166 | 1173 | |
1167 | 1174 | // if "no-alt-cycling" is enabled, Ctrl-Click arrives here. |
1168 | | if (ctrl) { |
| 1175 | if (platformMenuShortcutKeyMask) { |
1169 | 1176 | // a member of cycleList was found in the current dataset selection |
1170 | 1177 | if (foundInDS != null) { |
1171 | 1178 | // mouse was moved to a different selection group w/ a previous sel |
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;
|
26 | 26 | import org.openstreetmap.josm.data.osm.visitor.paint.PaintColors; |
27 | 27 | import org.openstreetmap.josm.gui.layer.AbstractMapViewPaintable; |
28 | 28 | import org.openstreetmap.josm.tools.ColorHelper; |
| 29 | import org.openstreetmap.josm.tools.PlatformManager; |
29 | 30 | |
30 | 31 | /** |
31 | 32 | * Manages the selection of a rectangle or a lasso loop. Listening to left and right mouse button |
… |
… |
public class SelectionManager implements MouseListener, MouseMotionListener, Pro
|
185 | 186 | if (e.getButton() == MouseEvent.BUTTON1 && e.getClickCount() > 1 && MainApplication.getLayerManager().getActiveDataSet() != null) { |
186 | 187 | SelectByInternalPointAction.performSelection(MainApplication.getMap().mapView.getEastNorth(e.getX(), e.getY()), |
187 | 188 | (e.getModifiersEx() & MouseEvent.SHIFT_DOWN_MASK) != 0, |
188 | | (e.getModifiersEx() & MouseEvent.CTRL_DOWN_MASK) != 0); |
| 189 | (e.getModifiersEx() & PlatformManager.getPlatform().getMenuShortcutKeyMaskEx()) != 0); |
189 | 190 | } else if (e.getButton() == MouseEvent.BUTTON1) { |
190 | 191 | mousePosStart = mousePos = e.getPoint(); |
191 | 192 | |