Skip to content

Commit

Permalink
Use vertical bar for selecting parent ways instead of command+up arro…
Browse files Browse the repository at this point in the history
…w (re: #8264)

Support pressing vertical bar again to return to node selection
  • Loading branch information
quincylvania committed Jan 6, 2021
1 parent b0df313 commit ddf8682
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 8 deletions.
3 changes: 1 addition & 2 deletions data/shortcuts.json
Original file line number Diff line number Diff line change
Expand Up @@ -159,8 +159,7 @@
"text": "shortcuts.browsing.vertex_selected.last"
},
{
"modifiers": [""],
"shortcuts": [""],
"shortcuts": ["|"],
"text": "shortcuts.browsing.vertex_selected.parent"
},
{
Expand Down
30 changes: 24 additions & 6 deletions modules/modes/select.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ export function modeSelect(context, selectedIDs) {
// `_focusedParentWayId` is used when we visit a vertex with multiple
// parents, and we want to remember which parent line we started on.
var _focusedParentWayId;
var _focusedVertexIds;


function singular() {
Expand Down Expand Up @@ -243,7 +244,7 @@ export function modeSelect(context, selectedIDs) {
.on(utilKeybinding.minusKeys.map((key) => uiCmd('⇧' + key)), scaleSelection(1/1.05))
.on(utilKeybinding.minusKeys.map((key) => uiCmd('⇧⌥' + key)), scaleSelection(1/Math.pow(1.05, 5)))
.on(['\\', 'pause'], focusNextParent)
.on(uiCmd('⌘↑'), selectParent)
.on('|', selectParent)
.on('⎋', esc, true);

d3_select(document)
Expand Down Expand Up @@ -572,12 +573,27 @@ export function modeSelect(context, selectedIDs) {

function selectParent(d3_event) {
d3_event.preventDefault();
var parents = _focusedParentWayId ? [_focusedParentWayId] : parentWaysIdsOfSelection(false);
if (!parents || parents.length === 0) return;

context.enter(
modeSelect(context, parents)
);
var currentSelectedIds = mode.selectedIDs();
var parentIds = _focusedParentWayId ? [_focusedParentWayId] : parentWaysIdsOfSelection(false);

if (!parentIds.length) {
var reselectIds = _focusedVertexIds && _focusedVertexIds.filter(id => context.hasEntity(id));

if (reselectIds && reselectIds.length) {
if (currentSelectedIds.length === 1) _focusedParentWayId = currentSelectedIds[0];
context.enter(
mode.selectedIDs(_focusedVertexIds)
);
}
} else {

context.enter(
mode.selectedIDs(parentIds)
);
// set this after re-entering the selection since we normally want it cleared on exit
_focusedVertexIds = currentSelectedIds;
}
}
};

Expand All @@ -587,6 +603,8 @@ export function modeSelect(context, selectedIDs) {
// we could enter the mode multiple times but it's only new the first time
_newFeature = false;

_focusedVertexIds = null;

_operations.forEach(function(operation) {
if (operation.behavior) {
context.uninstall(operation.behavior);
Expand Down
2 changes: 2 additions & 0 deletions modules/util/keybinding.js
Original file line number Diff line number Diff line change
Expand Up @@ -370,6 +370,8 @@ utilKeybinding.keyCodes = {
'+': 107, 'plus': 107,
// Num-Subtract, or -
'-': 109, subtract: 109,
// Vertical Bar / Pipe
'|': 124,
// Firefox Plus
'ffplus': 171,
// Firefox Minus
Expand Down

0 comments on commit ddf8682

Please sign in to comment.