-
Hi all! Currently the rete-connection-plugin's event Glad to here your input, |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
FYI why I need this: I want to create a new node programatically (without context menu) if user drops a connection in to free space. That's why I need to know if My first intention was to to fork rete-connection-plugin and change the Pseudocode solution: let createNode = false;
editor.on('connectionpick', handlePick);
editor.on('connectiondrop', handleDrop);
window.addEventListener('pointerup', handlePointerUp, { capture: true });
function handlePick(io) {
createNode = true;
}
// Happening before handleDrop execution.
function handlePointerUp(e) {
const targetElement = document.elementFromPoint(e.clientX, e.clientY); // Detect which HTML element was targeted.
if (targetElement.classList.contains("socket")) { // Check if it is a socket.
createNode = false;
}
};
function handleDrop(io) {
if (createNode) {
// TODO: Manually create a node here.
} else {
// Dropped on a socket, do nothing.
}
} |
Beta Was this translation helpful? Give feedback.
FYI why I need this: I want to create a new node programatically (without context menu) if user drops a connection in to free space. That's why I need to know if
connectiondrop
has happened on a socket or not.My first intention was to to fork rete-connection-plugin and change the
connectiondrop
event arguments. But finally I went with kind of "duplicating" some of the logic happening in rete-connection-plugin inside the capture phase of window'spointerup
event, which will hapen before the connectiondrop event fires (both use same window event, but the package not in the capture phase).Pseudocode solution: