Cancel rightButtonPress event

I am using CellPicker to achieving picking cells with vtk.js and I want to cancel rightButtonPress event after using renderWindow.getInteractor().onRightButtonPress. I have been searching for a long time and have not found a suitable function. I hope someone can help me, thanks.

You can abort the event handling chain:

import { EVENT_ABORT } from 'vtk.js/Sources/macro';

renderWindow.getInteractor().onRightButtonPress(() => {
   ...
   return EVENT_ABORT;
});

thank you for your reply,but there are still some problems.This is part of my code:

cellPick = (item) => {
const picker=vtkCellPicker.newInstance();
picker.setPickFromList(true);
picker.setTolerance(0);
picker.initializePickList();
picker.addPickList(this.curScene[item._attributes.name].actor);
this.renderWindow.getInteractor().onRightButtonPress((callData)=>{
if(this.renderer !== callData.pokedRenderer){
return;
}
const pos=callData.position;
const point=[pos.x,pos.y,0.0];
console.log(Pick at: ${point});
picker.pick(point,this.renderer);
if (picker.getActors().length === 0) {
const pickedPoint = picker.getPickPosition();
console.log(No cells picked, default: ${pickedPoint});
}
else {
const pickedCellId = picker.getCellId();
console.log('Picked cell: ', pickedCellId);
const pickedPoints = picker.getPickedPositions();
for (let i = 0; i < pickedPoints.length; i++) {
const pickedPoint = pickedPoints[i];
console.log(Picked: ${pickedPoint});
}
}
return EVENT_ABORT; // It doesn‘t seem to work…
});
}

<BiPointer type=“regular” onClick={() => this.cellPick(item)}>

I have more than one polydata in the scene and I want to be able to pick a polydata’s cell by click its BiPointer icon. I used ‘return EVENT_ABORT;’,but the renderWindow still responds to the RightButtonPress event. What’s even more strange is that when I want to click on other icons to pick cells of other polydatas, the console prints No cells picked, default: ${pickedPoint}.I’m not sure if I express it clearly,I just want to control the cellPick of different polydatas by turning on or off the RightButtonPress event. Can you give me some advices? Thank you very much!

Ah, EVENT_ABORT only is useful when you want to stop early-terminate an event’s callback chain. If you want to cancel a RightButtonPress event, you call unsubscribe() on the object that the listener returns:

const subscription = this.renderWindow.getInteractor().onRightButtonPress((callData)=> { ... });
...
// when you want to cancel/remove that particular event listener
subscription.unsubscribe();

I succeeded according to what you said, thanks again! :smiley: