Enable nudging the selection via shift+arrow keys and shift+command+arrow keys to nudge more (close #7186)

No longer nudge the viewport with shift+arrow keys
This commit is contained in:
Quincy Morgan
2020-05-19 12:08:14 -04:00
parent c4f5dbbc4c
commit 311566328e
5 changed files with 50 additions and 4 deletions

View File

@@ -2053,6 +2053,8 @@ en:
split: "Split a line into two at the selected node"
reverse: "Reverse selected features"
move: "Move selected features"
nudge: "Nudge selected features"
nudge_more: "Nudge selected features by a lot"
rotate: "Rotate selected features"
orthogonalize: "Square corners of a line or area"
straighten: "Straighten a line or points"

View File

@@ -269,6 +269,18 @@
"shortcuts": ["operations.move.key"],
"text": "shortcuts.editing.operations.move"
},
{
"modifiers": ["⇧"],
"shortcuts": ["↓", "↑", "←", "→"],
"text": "shortcuts.editing.operations.nudge",
"separator": ","
},
{
"modifiers": ["⌘", "⇧"],
"shortcuts": ["↓", "↑", "←", "→"],
"text": "shortcuts.editing.operations.nudge_more",
"separator": ","
},
{
"shortcuts": ["operations.rotate.key"],
"text": "shortcuts.editing.operations.rotate"

View File

@@ -2528,6 +2528,8 @@
"split": "Split a line into two at the selected node",
"reverse": "Reverse selected features",
"move": "Move selected features",
"nudge": "Nudge selected features",
"nudge_more": "Nudge selected features by a lot",
"rotate": "Rotate selected features",
"orthogonalize": "Square corners of a line or area",
"straighten": "Straighten a line or points",

View File

@@ -4,6 +4,7 @@ import { t } from '../core/localizer';
import { actionAddMidpoint } from '../actions/add_midpoint';
import { actionDeleteRelation } from '../actions/delete_relation';
import { actionMove } from '../actions/move';
import { behaviorBreathe } from '../behavior/breathe';
import { behaviorHover } from '../behavior/hover';
@@ -11,6 +12,8 @@ import { behaviorLasso } from '../behavior/lasso';
import { behaviorPaste } from '../behavior/paste';
import { behaviorSelect } from '../behavior/select';
import { operationMove } from '../operations/move';
import { geoExtent, geoChooseEdge } from '../geo';
import { modeBrowse } from './browse';
import { modeDragNode } from './drag_node';
@@ -212,6 +215,14 @@ export function modeSelect(context, selectedIDs) {
.on([']', 'pgdown'], nextVertex)
.on(['{', uiCmd('⌘['), 'home'], firstVertex)
.on(['}', uiCmd('⌘]'), 'end'], lastVertex)
.on(uiCmd('⇧←'), nudgeSelection([-10, 0]))
.on(uiCmd('⇧↑'), nudgeSelection([0, -10]))
.on(uiCmd('⇧→'), nudgeSelection([10, 0]))
.on(uiCmd('⇧↓'), nudgeSelection([0, 10]))
.on(uiCmd('⇧⌘←'), nudgeSelection([-100, 0]))
.on(uiCmd('⇧⌘↑'), nudgeSelection([0, -100]))
.on(uiCmd('⇧⌘→'), nudgeSelection([100, 0]))
.on(uiCmd('⇧⌘↓'), nudgeSelection([0, 100]))
.on(['\\', 'pause'], nextParent)
.on('⎋', esc, true);
@@ -258,6 +269,24 @@ export function modeSelect(context, selectedIDs) {
}
function nudgeSelection(delta) {
return function() {
d3_event.stopImmediatePropagation();
var moveOp = operationMove(context, selectedIDs);
if (moveOp.disabled()) {
context.ui().flash
.duration(4000)
.iconName('#iD-operation-' + moveOp.id)
.iconClass('operation disabled')
.text(moveOp.tooltip)();
} else {
context.perform(actionMove(selectedIDs, delta, context.projection), moveOp.annotation());
}
};
}
function didDoubleUp(loc) {
if (!context.map().withinEditableZoom()) return;

View File

@@ -319,10 +319,10 @@ export function uiInit(context) {
.on('↑', pan([0, panPixels]))
.on('→', pan([-panPixels, 0]))
.on('↓', pan([0, -panPixels]))
.on(['⇧←', uiCmd('⌘←')], pan([map.dimensions()[0], 0]))
.on(['⇧↑', uiCmd('⌘↑')], pan([0, map.dimensions()[1]]))
.on(['⇧→', uiCmd('⌘→')], pan([-map.dimensions()[0], 0]))
.on(['⇧↓', uiCmd('⌘↓')], pan([0, -map.dimensions()[1]]))
.on(uiCmd('⌘←'), pan([map.dimensions()[0], 0]))
.on(uiCmd('⌘↑'), pan([0, map.dimensions()[1]]))
.on(uiCmd('⌘→'), pan([-map.dimensions()[0], 0]))
.on(uiCmd('⌘↓'), pan([0, -map.dimensions()[1]]))
.on(uiCmd('⌘' + t('background.key')), function quickSwitch() {
if (d3_event) {
d3_event.stopImmediatePropagation();
@@ -399,6 +399,7 @@ export function uiInit(context) {
function pan(d) {
return function() {
if (d3_event.shiftKey) return;
if (context.container().select('.combobox').size()) return;
d3_event.preventDefault();
context.map().pan(d, 100);