1
0
mirror of https://github.com/node-red/node-red.git synced 2023-10-10 13:36:53 +02:00

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

View File

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