Calling selectionManager.add with suppressCallback to be true, still triggers selectionArray callback

Based on the docs here, if I pass true to the second parameter when I am adding a selectionItem, selectionArray should not be triggered. It doesn’t get triggered if the node is not already in the selection. However, if I select I add it twice, it gets triggered…

  1. run viewer.selectionManager.add([Communicator.Selection.SelectionItem.create(nodeNumber)], true)
  2. selectionArray callback on webViewer doesn’t get called
  3. Then run the same line again
  4. selectionArray callback on webViewer gets triggered

Is this intentional or a bug?

Thank you!

Hello @mark.aronin,

We’ll create a support ticket on your behalf and have our Communicator development team take a closer look at the behavior.

One quick note is that for the second call that triggers the callback, it’s possible to “catch” the callback because the returned selection events array is empty:

        selectionArray: function (selections) {
		if (selections.length === 0) {
			console.log("selections is empty");
		} else {


Thank for the quick reply Tino! We could check for the selections.length, but it’s not reliable in our case.

I’d like to also mention that doing viewer.selectionManager.selectNode(nodeNumber, Communicator.SelectionMode.Add); when the node is already selected yields an empty selectionArray also.

Another question:

Is there a way to intercept the selectionManager for nodes being added/removed/toggled? Like providing our own custom selectionManager which extends the original Hoops Communicator SelectionManager? We would like to perform some operations on nodes right before they are selected or unselected.

Thanks again!

Hello @mark.aronin,

A callback that could be helpful is incrementalSelectionBatchBegin (and complimentary callbacks incrementalSelectionBatchEnd and incrementalSelectionEnd). As stated in our docs, incrementalSelectionBatchBegin is

Triggered BEFORE a batch of incrementally selected entities is put into the SelectionManager

I also wanted to briefly mention the function setSelectionFilter. While this function does not pre-empt a selection operation, it can be handy if you want to quickly manipulate certain nodes. An example is provided in this forum post.

If this post doesn’t fully address the requirements of your particular workflow, we kindly request that you create a feature request via our Communicator Support Portal. Please include the necessary technical details to assist us in a more comprehensive evaluation.


1 Like

Thanks Tino!

What you mentioned doesn’t fully work for our use case, but it’s good to know that this is available. I think we will just track what we have selected or not through the selectionArray callback by checking the selectionManager and updating our tracker object.

Thanks again for all your support!