# incrementalSelectionEnd should be trigger

**URL:** https://forum.techsoft3d.com/t/incrementalselectionend-should-be-trigger/3958
**Category:** HOOPS Visualize Web
**Created:** [August 16, 2024, 3:41am UTC](https://forum.techsoft3d.com/t/incrementalselectionend-should-be-trigger/3958 "2024-08-16T03:41:37Z")
**Posts on this page:** 7
**Page:** 1

<div class="post-metadata">

### Author: ![15089700278](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.techsoft3d.com/15089700278/32/1571_2.png) [@15089700278](https://forum.techsoft3d.com/u/15089700278)
#### Post date: [August 16, 2024, 3:41am UTC](https://forum.techsoft3d.com/t/incrementalselectionend-should-be-trigger/3958/1 "2024-08-16T03:41:37Z")

</div>

```auto
// simple tree
[
  { "nodeId": 4 },
  { "nodeId": 5, "children": [{ "nodeId": 31 }, { "nodeId": 32 }] }
]
hwv.selectionManager.selectPart(4, Communicator.SelectionMode.Toggle);
hwv.selectionManager.selectPart(5, Communicator.SelectionMode.Toggle);
hwv.selectionManager.selectPart(31, Communicator.SelectionMode.Toggle);

```

After executing `incrementalSelectionBatchBegin`, `incrementalSelectionEnd` should be triggered. However, in the scenario described above, only `incrementalSelectionBatchBegin` and `incrementalSelectionBatchEnd` are triggered.

To optimize performance, I need to handle certain logic only after all batch selections are completed.

---

<div class="post-metadata">

### Author: ![tino](https://avatars.discourse-cdn.com/v4/letter/t/9dc877/32.png) [@tino](https://forum.techsoft3d.com/u/tino)
#### Post date: [August 16, 2024, 12:09pm UTC](https://forum.techsoft3d.com/t/incrementalselectionend-should-be-trigger/3958/2 "2024-08-16T12:09:05Z")

</div>

Hello @15089700278,

The callback [incrementalSelectionEnd](https://docs.techsoft3d.com/communicator/latest/api_ref/viewing/interfaces/Communicator.CallbackMap.html#Communicator.CallbackMap.incrementalSelectionEnd) is triggered when the function [endIncrementalSelection](https://docs.techsoft3d.com/communicator/latest/api_ref/viewing/classes/Communicator.SelectionManager.html#Communicator.SelectionManager.endIncrementalSelection) is called. For an example, please refer to the code snippets provided in our docs covering selection, such as the [ray drill selection example](https://docs.techsoft3d.com/communicator/latest/prog_guide/viewing/selection-and-picking.html#ray-drill-selection).

Also, the default area selection operator will trigger these callbacks too.

Thanks,  
Tino

---

<div class="post-metadata">

### Author: ![15089700278](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.techsoft3d.com/15089700278/32/1571_2.png) [@15089700278](https://forum.techsoft3d.com/u/15089700278)
#### Post date: [August 19, 2024, 3:41am UTC](https://forum.techsoft3d.com/t/incrementalselectionend-should-be-trigger/3958/3 "2024-08-19T03:41:04Z")

</div>

Hello @tino

I hope to add a callback to `incrementalSelectionStart` so that I can reduce operations when dealing with some complex selections.

```auto
let inIncrementalSelectioin = false;
hwv.setCallbacks({
  selectionArray: () => {
    if (!inIncrementalSelectioin) {
      // Handle complex computational logic
    }
  },
  incrementalSelectionStart: () => {
    inIncrementalSelectioin = true;
  },
  incrementalSelectionEnd: () => {
    inIncrementalSelectioin = false;
    hwv._callbackManager.trigger('selectionArray', xxx, xxx);
  },
});

```

Thanks,  
Easoncan

---

<div class="post-metadata">

### Author: ![tino](https://avatars.discourse-cdn.com/v4/letter/t/9dc877/32.png) [@tino](https://forum.techsoft3d.com/u/tino)
#### Post date: [August 19, 2024, 12:31pm UTC](https://forum.techsoft3d.com/t/incrementalselectionend-should-be-trigger/3958/4 "2024-08-19T12:31:15Z")

</div>

You referenced `incrementalSelectionStart` as a callback. However, such a callback does not already exist. For clarity, is your intention to create your own callback?

---

<div class="post-metadata">

### Author: ![15089700278](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.techsoft3d.com/15089700278/32/1571_2.png) [@15089700278](https://forum.techsoft3d.com/u/15089700278)
#### Post date: [August 20, 2024, 3:12am UTC](https://forum.techsoft3d.com/t/incrementalselectionend-should-be-trigger/3958/5 "2024-08-20T03:12:26Z")

</div>

Yes, there is no in the official callback, I hope that the official can increase the corresponding Start Callback to process complex computing logic, Thanks.

---

<div class="post-metadata">

### Author: ![tino](https://avatars.discourse-cdn.com/v4/letter/t/9dc877/32.png) [@tino](https://forum.techsoft3d.com/u/tino)
#### Post date: [August 20, 2024, 5:39pm UTC](https://forum.techsoft3d.com/t/incrementalselectionend-should-be-trigger/3958/6 "2024-08-20T17:39:01Z")

</div>

There is the callback [incrementalSelectionBatchBegin](https://docs.techsoft3d.com/communicator/latest/api_ref/viewing/interfaces/Communicator.CallbackMap.html#Communicator.CallbackMap.incrementalSelectionBatchBegin). Is this particular callback insufficient for your workflow?

---

<div class="post-metadata">

### Author: ![15089700278](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.techsoft3d.com/15089700278/32/1571_2.png) [@15089700278](https://forum.techsoft3d.com/u/15089700278)
#### Post date: [August 21, 2024, 5:55am UTC](https://forum.techsoft3d.com/t/incrementalselectionend-should-be-trigger/3958/7 "2024-08-21T05:55:56Z")

</div>

In my first example, `incrementalSelectionBatchBegin` was triggered, but `incrementalSelectionEnd` was not triggered, resulting in no complete closed loop.
