# How to catch mouse click events(right mouse button)in a VTK Chart

**URL:** https://discourse.vtk.org/t/how-to-catch-mouse-click-events-right-mouse-button-in-a-vtk-chart/9876
**Category:** Support
**Created:** [November 18, 2022, 5:29am UTC](https://discourse.vtk.org/t/how-to-catch-mouse-click-events-right-mouse-button-in-a-vtk-chart/9876 "2022-11-18T05:29:05Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![we\_create](https://discourse.vtk.org/user_avatar/discourse.vtk.org/we_create/32/5917_2.png) [@we\_create](https://discourse.vtk.org/u/we_create)
#### Post date: [November 18, 2022, 5:29am UTC](https://discourse.vtk.org/t/how-to-catch-mouse-click-events-right-mouse-button-in-a-vtk-chart/9876/1 "2022-11-18T05:29:05Z")

</div>

Hi all  
I just want to add userinteraction(rigth mouse click) to a vtk chart .can anyone please guide me .  
This is what I have done upto now.But nothing happend.

class customMouseInteractorStyle : public vtkInteractorStyleTrackballCamera  
{  
public:  
static customMouseInteractorStyle\* New();  
vtkTypeMacro(customMouseInteractorStyle, vtkInteractorStyleTrackballCamera);

```
virtual void OnRightButtonDown();

```

};

vtkStandardNewMacro(customMouseInteractorStyle);

void customMouseInteractorStyle::OnRightButtonDown()  
{  
vtkInteractorStyleTrackballCamera::OnRightButtonDown();

```
std::cout << "test";

```

};

void viewGraph::DrawGraph() {  
vtkNew colors;

vtkNew style;  
renderWindowInteractor-\>SetInteractorStyle(style);  
}

\*\*Inside my DrawGraph() I have created my xy chart

Thank you in advance.

---

<div class="post-metadata">

### Author: ![drpeterfranz](https://discourse.vtk.org/letter_avatar_proxy/v4/letter/d/f19dbf/32.png) [@drpeterfranz](https://discourse.vtk.org/u/drpeterfranz)
#### Post date: [November 19, 2022, 3:26pm UTC](https://discourse.vtk.org/t/how-to-catch-mouse-click-events-right-mouse-button-in-a-vtk-chart/9876/2 "2022-11-19T15:26:42Z")

</div>

VtkChart is a subclass of vtkAbstractContextItem which handles its own mouse events. So subclass vtkChart and then override the mouse handling methods directly there, not in the interactor style.

---

<div class="post-metadata">

### Author: ![we\_create](https://discourse.vtk.org/user_avatar/discourse.vtk.org/we_create/32/5917_2.png) [@we\_create](https://discourse.vtk.org/u/we_create)
#### Post date: [November 24, 2022, 4:13am UTC](https://discourse.vtk.org/t/how-to-catch-mouse-click-events-right-mouse-button-in-a-vtk-chart/9876/3 "2022-11-24T04:13:49Z")

</div>

thank you and got it.
