-
-
Notifications
You must be signed in to change notification settings - Fork 774
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
How to restrict the node to single input #35
Comments
Hello @freesix Thanks! ❤️ An input could be restricted with functions and events. Or you can modify the library. For example: editor.on("connectionCreated", function(info) {
const nodeInfo = editor.getNodeFromId(info.input_id);
if(nodeInfo.inputs[info.input_class].connections.length > 1) {
const removeConnectionInfo = nodeInfo.inputs[info.input_class].connections[0];
editor.removeSingleConnection(removeConnectionInfo.node, info.input_id, removeConnectionInfo.input, info.input_class);
}
}); This example deletes the first connection and only keeps the last one. |
Thank you @jerosoler How can we do the same for output. Output only to bind to an input |
Hello @muratcim Following the example above. For example: editor.on("connectionCreated", function(info) {
const nodeInfo = editor.getNodeFromId(info.output_id);
if(nodeInfo.outputs[info.output_class].connections.length > 1) {
const removeConnectionInfo = nodeInfo.outputs[info.output_class].connections[0];
editor.removeSingleConnection(info.output_id, removeConnectionInfo.node, info.output_class, removeConnectionInfo.output);
}
}); |
Thank you @jerosoler Best Regards |
@jerosoler
But according to the instructions above, |
It is only called if a connection is deleted. |
@jerosoler |
You can create something like this. let deleteConnectionAuto = false;
editor.on("connectionCreated", function(info) {
const nodeInfo = editor.getNodeFromId(info.output_id);
if(nodeInfo.outputs[info.output_class].connections.length > 1) {
const removeConnectionInfo = nodeInfo.outputs[info.output_class].connections[0];
deleteConnectionAuto = true;
editor.removeSingleConnection(info.output_id, removeConnectionInfo.node, info.output_class, removeConnectionInfo.output);
}
});
this.editor.on('connectionRemoved', (info) => {
if(!deleteConnectionAuto) {
// call delete api
} else {
deleteConnectionAuto = false;
}
}) |
@jerosoler i loving you !!!! |
I really like your project and willing to use it but I have a question according to my requirement.
Is it possible to restrict the node to a single input ?
Also, Can we customize it?
The text was updated successfully, but these errors were encountered: