Selecting nodes programmatically #873
-
I want to select a node by its ID from my code (not by clicking on it). How can I do this? |
Beta Was this translation helpful? Give feedback.
Answered by
bcakmakoglu
Apr 19, 2023
Replies: 1 comment 9 replies
-
By setting node.selected to true |
Beta Was this translation helpful? Give feedback.
9 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Sorry, I sent this message while outside so wasn't able to write a lot more than this 😄
There's a couple ways to select nodes programmatically but the easiest way is, as I mentioned, to just set
node.selected
totrue
For example:
And that's it, your node is now marked as selected :)
Alternatively there's the option to use the
addSelectedNodes
action.