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

Change slicing op to mouse button 0

fixes #3582
This commit is contained in:
Steve-Mcl 2022-05-13 16:43:27 +01:00
parent 03e9e89558
commit 7ec1d42808

View File

@ -955,8 +955,9 @@ RED.view = (function() {
} }
function canvasMouseDown() { function canvasMouseDown() {
if (RED.view.DEBUG) { console.warn("canvasMouseDown", mouse_mode); } if (RED.view.DEBUG) {
var point; console.warn("canvasMouseDown", { mouse_mode, point: d3.mouse(this), event: d3.event });
}
if (mouse_mode === RED.state.SELECTING_NODE) { if (mouse_mode === RED.state.SELECTING_NODE) {
d3.event.stopPropagation(); d3.event.stopPropagation();
return; return;
@ -973,45 +974,49 @@ RED.view = (function() {
selectedLinks.clear(); selectedLinks.clear();
updateSelection(); updateSelection();
} }
if (mouse_mode === 0) { if (mouse_mode === 0 && lasso) {
if (lasso) { lasso.remove();
lasso.remove(); lasso = null;
lasso = null;
}
} }
if ((mouse_mode === 0 || mouse_mode === RED.state.QUICK_JOINING) && (d3.event.touches || d3.event.button === 0) && (d3.event.metaKey || d3.event.ctrlKey)) { if (d3.event.touches || d3.event.button === 0) {
// Trigger quick add dialog if ((mouse_mode === 0 || mouse_mode === RED.state.QUICK_JOINING) && (d3.event.metaKey || d3.event.ctrlKey) && !(d3.event.altKey || d3.event.shiftKey)) {
d3.event.stopPropagation(); // Trigger quick add dialog
clearSelection(); d3.event.stopPropagation();
point = d3.mouse(this); clearSelection();
var clickedGroup = getGroupAt(point[0],point[1]); const point = d3.mouse(this);
if (drag_lines.length > 0) { var clickedGroup = getGroupAt(point[0], point[1]);
clickedGroup = clickedGroup || RED.nodes.group(drag_lines[0].node.g) if (drag_lines.length > 0) {
clickedGroup = clickedGroup || RED.nodes.group(drag_lines[0].node.g)
}
showQuickAddDialog({ position: point, group: clickedGroup });
} else if (mouse_mode === 0 && !(d3.event.metaKey || d3.event.ctrlKey)) {
// CTRL not being held
if (!d3.event.altKey) {
// ALT not held (shift is allowed) Trigger lasso
if (!touchStartTime) {
const point = d3.mouse(this);
lasso = eventLayer.append("rect")
.attr("ox", point[0])
.attr("oy", point[1])
.attr("rx", 1)
.attr("ry", 1)
.attr("x", point[0])
.attr("y", point[1])
.attr("width", 0)
.attr("height", 0)
.attr("class", "nr-ui-view-lasso");
d3.event.preventDefault();
}
} else if (d3.event.altKey) {
//Alt [+shift] held - Begin slicing
clearSelection();
mouse_mode = (d3.event.shiftKey) ? RED.state.SLICING_JUNCTION : RED.state.SLICING;
const point = d3.mouse(this);
slicePath = eventLayer.append("path").attr("class", "nr-ui-view-slice").attr("d", `M${point[0]} ${point[1]}`)
slicePathLast = point;
RED.view.redraw();
}
} }
showQuickAddDialog({position:point, group:clickedGroup});
} else if (mouse_mode === 0 && (d3.event.touches || d3.event.button === 0) && !(d3.event.metaKey || d3.event.ctrlKey)) {
// Tigger lasso
if (!touchStartTime) {
point = d3.mouse(this);
lasso = eventLayer.append("rect")
.attr("ox",point[0])
.attr("oy",point[1])
.attr("rx",1)
.attr("ry",1)
.attr("x",point[0])
.attr("y",point[1])
.attr("width",0)
.attr("height",0)
.attr("class","nr-ui-view-lasso");
d3.event.preventDefault();
}
} else if (mouse_mode === 0 && d3.event.button === 2 && (d3.event.metaKey || d3.event.ctrlKey || d3.event.shiftKey)) {
clearSelection();
mouse_mode = (d3.event.metaKey || d3.event.ctrlKey)?RED.state.SLICING : RED.state.SLICING_JUNCTION;
point = d3.mouse(this);
slicePath = eventLayer.append("path").attr("class","nr-ui-view-slice").attr("d",`M${point[0]} ${point[1]}`)
slicePathLast = point;
RED.view.redraw();
} }
} }
@ -1714,7 +1719,9 @@ RED.view = (function() {
function canvasMouseUp() { function canvasMouseUp() {
lastClickPosition = [d3.event.offsetX/scaleFactor,d3.event.offsetY/scaleFactor]; lastClickPosition = [d3.event.offsetX/scaleFactor,d3.event.offsetY/scaleFactor];
if (RED.view.DEBUG) { console.warn("canvasMouseUp", mouse_mode); } if (RED.view.DEBUG) {
console.warn("canvasMouseUp", { mouse_mode, point: d3.mouse(this), event: d3.event });
}
var i; var i;
var historyEvent; var historyEvent;
if (mouse_mode === RED.state.PANNING) { if (mouse_mode === RED.state.PANNING) {
@ -3712,6 +3719,9 @@ RED.view = (function() {
function junctionMouseOutProxy(e) { junctionMouseOut(d3.select(this), this.__data__) } function junctionMouseOutProxy(e) { junctionMouseOut(d3.select(this), this.__data__) }
function linkMouseDown(d) { function linkMouseDown(d) {
if (RED.view.DEBUG) {
console.warn("linkMouseDown", { mouse_mode, point: d3.mouse(this), event: d3.event });
}
if (mouse_mode === RED.state.SELECTING_NODE) { if (mouse_mode === RED.state.SELECTING_NODE) {
d3.event.stopPropagation(); d3.event.stopPropagation();
return; return;