Changeset 18456 in josm
- Timestamp:
- 2022-05-25T23:09:41+02:00 (2 years ago)
- Location:
- trunk/src/org/openstreetmap/josm
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/actions/mapmode/MapMode.java
r17157 r18456 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 … … 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 * {@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; 36 49 37 50 /** … … 155 168 156 169 /** 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. 158 171 * @param modifiers event extended modifiers mask 159 172 * @since 12517 … … 163 176 alt = (modifiers & (InputEvent.ALT_DOWN_MASK | InputEvent.ALT_GRAPH_DOWN_MASK)) != 0; 164 177 shift = (modifiers & InputEvent.SHIFT_DOWN_MASK) != 0; 178 meta = (modifiers & InputEvent.META_DOWN_MASK) != 0; 179 platformMenuShortcutKeyMask = (modifiers & PlatformManager.getPlatform().getMenuShortcutKeyMaskEx()) != 0; 165 180 } 166 181 -
trunk/src/org/openstreetmap/josm/actions/mapmode/SelectAction.java
r18274 r18456 4 4 import static org.openstreetmap.josm.gui.help.HelpUtil.ht; 5 5 import static org.openstreetmap.josm.tools.I18n.tr; 6 import static org.openstreetmap.josm.tools.I18n.trc; 6 7 import static org.openstreetmap.josm.tools.I18n.trn; 7 8 … … 9 10 import java.awt.Point; 10 11 import java.awt.Rectangle; 12 import java.awt.event.InputEvent; 11 13 import java.awt.event.KeyEvent; 12 14 import java.awt.event.MouseEvent; … … 288 290 289 291 // CTRL toggles selection, but if while dragging CTRL means merge 290 final boolean isToggleMode = ctrl&& !dragInProgress();292 final boolean isToggleMode = platformMenuShortcutKeyMask && !dragInProgress(); 291 293 if (c.isPresent() && (isToggleMode || !c.get().isSelected())) { 292 294 // only highlight primitives that will change the selection … … 318 320 // only consider merge if ctrl is pressed and there are nodes in 319 321 // the selection that could be merged 320 if (! ctrl|| getLayerManager().getEditDataSet().getSelectedNodes().isEmpty()) {322 if (!platformMenuShortcutKeyMask || getLayerManager().getEditDataSet().getSelectedNodes().isEmpty()) { 321 323 c = "move"; 322 324 break; … … 333 335 if (shift) { 334 336 c += "_add"; 335 } else if ( ctrl) {337 } else if (platformMenuShortcutKeyMask) { 336 338 c += osm == null || osm.isSelected() ? "_rm" : "_add"; 337 339 } … … 346 348 if (lassoMode) { 347 349 c = "lasso"; 350 } else if (shift) { 351 c = "rect_add"; 352 } else if (platformMenuShortcutKeyMask) { 353 c = "rect_rm"; 348 354 } else { 349 c = "rect" + (shift ? "_add" : (ctrl && !PlatformManager.isPlatformOsx() ? "_rm" : ""));355 c = "rect"; 350 356 } 351 357 break; … … 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; … … 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(); … … 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()) { … … 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 } … … 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 … … 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 … … 1018 1025 @Override 1019 1026 public String getModeHelpText() { 1027 // There needs to be a better way 1028 final String menuKey; 1029 switch (PlatformManager.getPlatform().getMenuShortcutKeyMaskEx()) { 1030 case InputEvent.CTRL_DOWN_MASK: 1031 menuKey = trc("SelectAction help", "Ctrl"); 1032 break; 1033 case InputEvent.META_DOWN_MASK: 1034 menuKey = trc("SelectAction help", "Meta"); 1035 break; 1036 default: 1037 throw new IllegalStateException("Unknown platform menu shortcut key for " + PlatformManager.getPlatform().getOSDescription()); 1038 } 1039 final String type = this.lassoMode ? trc("SelectAction help", "lasso") : trc("SelectAction help", "rectangle"); 1020 1040 if (mouseDownButton == MouseEvent.BUTTON1 && mouseReleaseTime < mouseDownTime) { 1021 1041 if (mode == Mode.SELECT) 1022 return tr("Release the mouse button to select the objects in the rectangle.");1042 return tr("Release the mouse button to select the objects in the {0}.", type); 1023 1043 else if (mode == Mode.MOVE && (System.currentTimeMillis() - mouseDownTime >= initialMoveDelay)) { 1024 1044 final DataSet ds = getLayerManager().getEditDataSet(); 1025 1045 final boolean canMerge = ds != null && !ds.getSelectedNodes().isEmpty(); 1026 final String mergeHelp = canMerge ? (' ' + tr(" Ctrl to merge with nearest node.")) : "";1046 final String mergeHelp = canMerge ? (' ' + tr("{0} to merge with nearest node.", menuKey)) : ""; 1027 1047 return tr("Release the mouse button to stop moving.") + mergeHelp; 1028 1048 } else if (mode == Mode.ROTATE) … … 1031 1051 return tr("Release the mouse button to stop scaling."); 1032 1052 } 1033 return tr("Move objects by dragging; Shift to add to selection ( Ctrl to toggle); Shift-Ctrlto rotate selected; " +1034 "Alt-Ctrl to scale selected; or change selection");1053 return tr("Move objects by dragging; Shift to add to selection ({0} to toggle); Shift-{0} to rotate selected; " + 1054 "Alt-{0} to scale selected; or change selection", menuKey); 1035 1055 } 1036 1056 … … 1107 1127 // true nearest primitive on mousePressed right away 1108 1128 if (cycleList.size() == 2 && !waitForMouseUpParameter) { 1109 if (!(osm.equals(old) || osm.isNew() || ctrl)) {1129 if (!(osm.equals(old) || osm.isNew() || platformMenuShortcutKeyMask)) { 1110 1130 cyclePrims = false; 1111 1131 osm = old; … … 1155 1175 foundInDS = nxt; 1156 1176 // first selected primitive in cycleList is found 1157 if (cyclePrims || ctrl) {1177 if (cyclePrims || platformMenuShortcutKeyMask) { 1158 1178 ds.clearSelection(foundInDS); // deselect it 1159 1179 nxt = i.hasNext() ? i.next() : first; … … 1166 1186 1167 1187 // if "no-alt-cycling" is enabled, Ctrl-Click arrives here. 1168 if ( ctrl) {1188 if (platformMenuShortcutKeyMask) { 1169 1189 // a member of cycleList was found in the current dataset selection 1170 1190 if (foundInDS != null) { -
trunk/src/org/openstreetmap/josm/actions/mapmode/SelectLassoAction.java
r18122 r18456 55 55 return MainApplication.getMap().mapModeSelect.layerIsSupported(l); 56 56 } 57 58 @Override 59 public String getModeHelpText() { 60 return MainApplication.getMap().mapModeSelect.getModeHelpText(); 61 } 57 62 } -
trunk/src/org/openstreetmap/josm/gui/SelectionManager.java
r16438 r18456 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 /** … … 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();
Note:
See TracChangeset
for help on using the changeset viewer.