# Cancel rightButtonPress event

**URL:** https://discourse.vtk.org/t/cancel-rightbuttonpress-event/4429
**Category:** Web
**Created:** [October 15, 2020, 5:01pm UTC](https://discourse.vtk.org/t/cancel-rightbuttonpress-event/4429 "2020-10-15T17:01:19Z")
**Posts on this page:** 5
**Page:** 1

<div class="post-metadata">

### Author: ![liyunfei18](https://discourse.vtk.org/user_avatar/discourse.vtk.org/liyunfei18/32/2691_2.png) [@liyunfei18](https://discourse.vtk.org/u/liyunfei18)
#### Post date: [October 15, 2020, 5:01pm UTC](https://discourse.vtk.org/t/cancel-rightbuttonpress-event/4429/1 "2020-10-15T17:01:19Z")

</div>

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.

---

<div class="post-metadata">

### Author: ![Forrest](https://discourse.vtk.org/user_avatar/discourse.vtk.org/forrest/32/300_2.png) [@Forrest](https://discourse.vtk.org/u/Forrest)
#### Post date: [October 15, 2020, 5:24pm UTC](https://discourse.vtk.org/t/cancel-rightbuttonpress-event/4429/2 "2020-10-15T17:24:33Z")

</div>

You can abort the event handling chain:

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

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

```

---

<div class="post-metadata">

### Author: ![liyunfei18](https://discourse.vtk.org/user_avatar/discourse.vtk.org/liyunfei18/32/2691_2.png) [@liyunfei18](https://discourse.vtk.org/u/liyunfei18)
#### Post date: [October 16, 2020, 4:31am UTC](https://discourse.vtk.org/t/cancel-rightbuttonpress-event/4429/3 "2020-10-16T04:31:54Z")

</div>

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!

---

<div class="post-metadata">

### Author: ![Forrest](https://discourse.vtk.org/user_avatar/discourse.vtk.org/forrest/32/300_2.png) [@Forrest](https://discourse.vtk.org/u/Forrest)
#### Post date: [October 16, 2020, 6:14pm UTC](https://discourse.vtk.org/t/cancel-rightbuttonpress-event/4429/4 "2020-10-16T18:14:01Z")

</div>

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:

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

```

---

<div class="post-metadata">

### Author: ![liyunfei18](https://discourse.vtk.org/user_avatar/discourse.vtk.org/liyunfei18/32/2691_2.png) [@liyunfei18](https://discourse.vtk.org/u/liyunfei18)
#### Post date: [October 17, 2020, 2:56am UTC](https://discourse.vtk.org/t/cancel-rightbuttonpress-event/4429/5 "2020-10-17T02:56:57Z")

</div>

I succeeded according to what you said, thanks again！ 😃
