Best way to handle dzScene->primarySelectionChanged() ?

vholfvholf Posts: 63

I've noticed that primarySelectionChanged() (and also nodeSelectionListChanged) gets triggered several times on a single select operation. I can see the nodes are selected and deselected and then selected again (alghough, for some reason node->isSelected() is always true).

What is the expected way to handle this event? I need to do some selection operations on the actual "scene->getPrimarySelection()", but the primary selection gets switched around in the process and I can't find a reliable flag to check.

I have tried to keep track of the selection stack, but I can't figure out a pattern, it goes from current to null to current and back again, and it gets worse when you select multiple nodes at once. There must be a proper way to handle it, any advice is very much welcome.

Post edited by vholf on

Comments

  • vholfvholf Posts: 63
    edited July 2022

    Some more experimenting and it seems that if I select nodes using the Viewport, each node selection event is fired once, but if I select it using the Scene tab (HierarchyPane) the node selection event is fired twice. I don't know if this is the expected behaviour but it is definitely a problem for what I intend to do.

    If I select a single node, I need to catch the node once all other nodes have been deselected, and if I select several, I need to get the list of nodes once all have been selected (as opposed to the nodeSelectionList growing on every call)

    Post edited by vholf on
Sign In or Register to comment.