pycodestyle
pycodestyle copied to clipboard
default clickCallBack
For onNodeClick we have call backs fired but nodes created with nodeCreate don’t receive a default clickCallBack.
Would be great if we could pass a default clickCallBack so that all nodes exhibit the same behavior.
I currently do something along the lines of this, which I think could be simplified if just worked with currentNode but not quite sure.
<script>
import { coreSvelvetStore } from "svelvet/stores/store";
const {
nodesStore,
nodeIdSelected
} = coreSvelvetStore;
$: $nodesStore, (() => {
const currentLength = $nodesStore.length - 1;
const lastNode = $nodesStore[currentLength]
if (lastLength < currentLength){
lastLength = currentLength;
if(lastNode && !('clickCallback' in lastNode)){
lastNode['clickCallback'] = defaultHandleClick; // our default handleClick function
nodesStore.set($nodesStore); // EditModal.svelte:34 ???
}
}
})();
</script>
In Svelvet 7, click handling is done via the on:nodeClicked action available on the Node component. A default callback could be created anywhere in your project and passed to each Node.
I'm not sure if this is what you're looking for, but we could have the event bubble up to the Svelvet component as well, so you could pass a function in just one place. I'd have to think about the use case and implementation. A more detailed description of what you're trying to achieve would be helpful, so I can tailor the approach!