select - differentiate parent/child selection

introduce more accessible shortcuts
This commit is contained in:
Milos Brzakovic
2021-07-13 19:51:32 +02:00
parent 49abb78251
commit c8f162b8f0
3 changed files with 31 additions and 17 deletions
+23 -16
View File
@@ -244,7 +244,8 @@ 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('|', selectParent)
.on(uiCmd('⌘↑'), selectParent)
.on(uiCmd('⌘↓'), selectChild)
.on('⎋', esc, true);
d3_select(document)
@@ -576,24 +577,30 @@ export function modeSelect(context, selectedIDs) {
var currentSelectedIds = mode.selectedIDs();
var parentIds = _focusedParentWayId ? [_focusedParentWayId] : parentWaysIdsOfSelection(false);
if (!parentIds.length) return;
if (!parentIds.length) {
var reselectIds = _focusedVertexIds && _focusedVertexIds.filter(id => context.hasEntity(id));
context.enter(
mode.selectedIDs(parentIds)
);
// set this after re-entering the selection since we normally want it cleared on exit
_focusedVertexIds = currentSelectedIds;
}
if (reselectIds && reselectIds.length) {
if (currentSelectedIds.length === 1) _focusedParentWayId = currentSelectedIds[0];
context.enter(
mode.selectedIDs(_focusedVertexIds)
);
}
} else {
function selectChild(d3_event) {
d3_event.preventDefault();
context.enter(
mode.selectedIDs(parentIds)
);
// set this after re-entering the selection since we normally want it cleared on exit
_focusedVertexIds = currentSelectedIds;
}
var currentSelectedIds = mode.selectedIDs();
var parentIds = _focusedParentWayId ? [_focusedParentWayId] : parentWaysIdsOfSelection(false);
if (parentIds.length) return;
var reselectIds = _focusedVertexIds && _focusedVertexIds.filter(id => context.hasEntity(id));
if (!reselectIds || !reselectIds.length) return;
if (currentSelectedIds.length === 1) _focusedParentWayId = currentSelectedIds[0];
context.enter(
mode.selectedIDs(_focusedVertexIds)
);
}
};