Make ctrl-click on nexted group more intuitive

This commit is contained in:
Nick O'Leary 2020-08-05 10:38:14 +01:00
parent a8e7627184
commit 1aa494a97a
No known key found for this signature in database
GPG Key ID: 4F2157149161A6C9
1 changed files with 34 additions and 13 deletions

View File

@ -2928,15 +2928,26 @@ RED.view = (function() {
var nodeGroup = RED.nodes.group(d.g); var nodeGroup = RED.nodes.group(d.g);
if (nodeGroup !== activeGroup && (d3.event.ctrlKey || d3.event.metaKey)) { if (nodeGroup !== activeGroup && (d3.event.ctrlKey || d3.event.metaKey)) {
// Clicked on a node in a non-active group with ctrl pressed if (activeGroup && nodeGroup.g === activeGroup.id) {
// - exit active group // Clicked on a node in a non-active group, inside the activeGroup, with ctrl pressed
// - toggle the select state of the group // - add/remove the group from the current selection
exitActiveGroup(); groupNodeSelectPrimed = true;
groupNodeSelectPrimed = true; if (nodeGroup.selected) {
if (nodeGroup.selected) { deselectGroup(nodeGroup);
deselectGroup(nodeGroup); } else {
selectGroup(nodeGroup,true);
}
} else { } else {
selectGroup(nodeGroup,true); // Clicked on a node in a non-active group with ctrl pressed
// - exit active group
// - toggle the select state of the group
exitActiveGroup();
groupNodeSelectPrimed = true;
if (nodeGroup.selected) {
deselectGroup(nodeGroup);
} else {
selectGroup(nodeGroup,true);
}
} }
} else if (nodeGroup === activeGroup ) { } else if (nodeGroup === activeGroup ) {
if (d3.event.shiftKey) { if (d3.event.shiftKey) {
@ -2958,9 +2969,14 @@ RED.view = (function() {
// Clicked on a node in the active group // Clicked on a node in the active group
if (!d3.event.ctrlKey && !d3.event.metaKey) { if (!d3.event.ctrlKey && !d3.event.metaKey) {
// Ctrl not pressed so clear selection // Ctrl not pressed so clear selection
var ag = activeGroup;
clearSelection(); clearSelection();
deselectGroup(nodeGroup); deselectGroup(nodeGroup);
selectGroup(nodeGroup,false,false); selectGroup(nodeGroup,false,false);
if (ag) {
enterActiveGroup(ag);
activeGroup.selected = true;
}
} }
// Select this node // Select this node
@ -2984,18 +3000,18 @@ RED.view = (function() {
clearSelection(); clearSelection();
} }
if (ag) { if (ag) {
if (ag !== nodeGroup) { if (ag !== nodeGroup && ag.id !== nodeGroup.g) {
ag.active = false; ag.active = false;
ag.dirty = true; ag.dirty = true;
} else { } else {
activeGroup = nodeGroup; activeGroup = ag;
activeGroup.active = true; activeGroup.active = true;
} }
} else { } else {
dblClickPrimed = false; dblClickPrimed = false;
} }
selectGroup(nodeGroup, !activeGroup, !!groupNodeSelectPrimed); selectGroup(nodeGroup, !(activeGroup && activeGroup === nodeGroup), !!groupNodeSelectPrimed);
if (activeGroup) { if (activeGroup && activeGroup === nodeGroup) {
mousedown_node.selected = true; mousedown_node.selected = true;
movingSet.add(mousedown_node); movingSet.add(mousedown_node);
} }
@ -3260,7 +3276,12 @@ RED.view = (function() {
} else { } else {
if (!g.selected) { if (!g.selected) {
if (!d3.event.ctrlKey && !d3.event.metaKey) { if (!d3.event.ctrlKey && !d3.event.metaKey) {
var ag = activeGroup;
clearSelection(); clearSelection();
if (ag && g.g === ag.id) {
enterActiveGroup(ag);
activeGroup.selected = true;
}
} }
if (activeGroup) { if (activeGroup) {
if (!RED.group.contains(activeGroup,g)) { if (!RED.group.contains(activeGroup,g)) {
@ -3270,7 +3291,7 @@ RED.view = (function() {
} }
} }
selectGroup(g,true);//!wasSelected); selectGroup(g,true);//!wasSelected);
} else { } else if (activeGroup && g.g !== activeGroup.id){
exitActiveGroup(); exitActiveGroup();
} }