How to remove an event from an interactor

Hi,
After adding an onLeftButtonPress in an GenericRenderWindow interactor, I want to remove this event listener, I didn’t find a way to do so,

I tried the unbindEvents() but it removes all Events from the interactor

You can add an observer to an interactor using AddObserver. An oberver is removed by RemoveObserver. I guess this is what you are looking for.

You can call the unsubscribe() method like this:

When adding a listener:
const listener = interactor.onLeftButtonPress(...)

When you want to remove:
listener.unsubscribe()

2 Likes

Unfortunately, this is not available in vtk.js

Thank you! worked for me!