Disable selection and focus on ViewerEvent.ObjectDoubleClicked

Hi @alex
By default the viewer is selecting and focusing on object when using double-click (or focusing the entire scene if double-clicked on no objects).
I would like to use double-click exclusively to show/hide dimensions. I already manage to do it with the code below, but it is in conflict with the default behavior (sometimes doing one, sometimes the other).
Is there a way to deactivate the default event?
Thanks!

const doubleClickedNode = event.hits[0].node;
        if (doubleClickedNode.model.raw.IsSketch === "yes") {
          const parentCollection = doubleClickedNode.parent;
          const dimensionsLinesProfiles =
            parentCollection.model.raw.Profiles.filter(
              (item: any) => !item.IsSketch
            );
          for (const profile of dimensionsLinesProfiles) {
            const filteringState = filtering.filteringState;
            if (filteringState.hiddenObjects.includes(profile.id)) {
              filtering.showObjects([profile.id]);
            } else {
              filtering.hideObjects([profile.id]);
            }
          }
        }

Hi @RaphaelVouilloz

Ideally, SelectionExtension should have an option that enables/disables it’s default double click behavior. We’ll take this into account when doing our next iteration.

Until then, you can simply erase the double click handler from SelectionExtension by extending it like so:

class CustomSelectionExtension extends SelectionExtension {
  /** Erase the double click default handler */
  protected onObjectClicked(selection: SelectionEvent) {
    // No-op
  }
}

Or if you already have already extended SelectionExtension in your application, you can do that in there of course

Cheers

1 Like

Yes, it works, thanks @alex :smiley_spockle:
I have slightly modified:

class CustomSelectionExtension extends SelectionExtension {
  protected onObjectDoubleClick(_selection: SelectionEvent): void {
  }
}
1 Like

Yep, you’re right, good catch! :smiley_spockle:

1 Like