pycodestyle icon indicating copy to clipboard operation
pycodestyle copied to clipboard

Event for when node is selected?

Open DanielSidhion opened this issue 2 years ago • 0 comments

I want to run some code whenever a node gets selected or deselected. I know that Node provides a selected prop through a let: directive, but due to how Svelte's let: directives work, there isn't an easy way of running some code whenever that value changes. Currently, my workaround hack is to have the following code:

<script>
  function nodeSelected(value) {
    // Do something here.
  }
</script>

<Node let:selected ...>
  {@const _ = nodeSelected(selected)}
</Node>

Node has nodeClicked and nodeReleased events, but they're not 100% the same as selected. For example, if someone selects a node by dragging a selection box around it, none of those events get fired, but the node still gets selected.

Is there a way a node can get an event when it gets selected or deselected? I'm willing to contribute a PR, but I'm asking here before spending time to code this.

DanielSidhion avatar Aug 02 '23 06:08 DanielSidhion