# Implementing Crosshair Movement on Mouse Click in MPR Viewer Using vtlResliceCursorWidget

**URL:** https://discourse.vtk.org/t/implementing-crosshair-movement-on-mouse-click-in-mpr-viewer-using-vtlreslicecursorwidget/12770
**Category:** vtk.js
**Tags:** code
**Created:** [November 22, 2023, 9:59am UTC](https://discourse.vtk.org/t/implementing-crosshair-movement-on-mouse-click-in-mpr-viewer-using-vtlreslicecursorwidget/12770 "2023-11-22T09:59:14Z")
**Posts on this page:** 6
**Page:** 1

<div class="post-metadata">

### Author: ![RajKanjariya](https://discourse.vtk.org/letter_avatar_proxy/v4/letter/r/a183cd/32.png) [@RajKanjariya](https://discourse.vtk.org/u/RajKanjariya)
#### Post date: [November 22, 2023, 9:59am UTC](https://discourse.vtk.org/t/implementing-crosshair-movement-on-mouse-click-in-mpr-viewer-using-vtlreslicecursorwidget/12770/1 "2023-11-22T09:59:14Z")

</div>

I am currently working on a project that involves implementing a functionality in the MPR viewer. Specifically, I am using the vtlResliceCursorWidget and aiming to synchronize the crosshair movement with mouse clicks in such a way that the selected slide updates accordingly. Additionally, I want to ensure that the crosshair movement corresponds to changes in the slider position.

I would greatly appreciate any insights, guidance, or code examples you may have regarding this integration. If anyone has experience or knowledge in this area, your assistance would be invaluable. Thank you in advance for your time and support.  
@finetjul@rajajms

---

<div class="post-metadata">

### Author: ![finetjul](https://discourse.vtk.org/user_avatar/discourse.vtk.org/finetjul/32/154_2.png) [@finetjul](https://discourse.vtk.org/u/finetjul)
#### Post date: [November 22, 2023, 11:07am UTC](https://discourse.vtk.org/t/implementing-crosshair-movement-on-mouse-click-in-mpr-viewer-using-vtlreslicecursorwidget/12770/2 "2023-11-22T11:07:29Z")

</div>

I’m not sure to undertand the difference between what you want to achieve and the existing [vtkResliceCursorWidget example](https://kitware.github.io/vtk-js/examples/ResliceCursorWidget.html).

---

<div class="post-metadata">

### Author: ![RajKanjariya](https://discourse.vtk.org/letter_avatar_proxy/v4/letter/r/a183cd/32.png) [@RajKanjariya](https://discourse.vtk.org/u/RajKanjariya)
#### Post date: [November 22, 2023, 11:29am UTC](https://discourse.vtk.org/t/implementing-crosshair-movement-on-mouse-click-in-mpr-viewer-using-vtlreslicecursorwidget/12770/4 "2023-11-22T11:29:19Z")

</div>

Thank you for your response. I’ll provide some clarification on my query. While the vtkResliceCursorWidget example is indeed a helpful resource, my specific use case involves the vtlResliceCursorWidget. I am looking for guidance on synchronizing the movement of the crosshair in the MPR viewer with mouse clicks, ensuring that the selected slide updates correspondingly. Additionally, I attached the video for more clarity.

---

<div class="post-metadata">

### Author: ![finetjul](https://discourse.vtk.org/user_avatar/discourse.vtk.org/finetjul/32/154_2.png) [@finetjul](https://discourse.vtk.org/u/finetjul)
#### Post date: [November 22, 2023, 11:39am UTC](https://discourse.vtk.org/t/implementing-crosshair-movement-on-mouse-click-in-mpr-viewer-using-vtlreslicecursorwidget/12770/5 "2023-11-22T11:39:51Z")

</div>

Gotcha, you would like to implement a “jump to mouse position” feature.  
You would need to edit the ResliceCursorWidget/behavior.js file, and notably the `handleLeftButtonDown`, `handleMouseMove` (to detect if the mouse was moved while the mouse button was down) and `handleLeftButtonRelease` (to perform the `jump`, i.e. call `setCenter()`)

---

<div class="post-metadata">

### Author: ![RajKanjariya](https://discourse.vtk.org/letter_avatar_proxy/v4/letter/r/a183cd/32.png) [@RajKanjariya](https://discourse.vtk.org/u/RajKanjariya)
#### Post date: [November 22, 2023, 11:51am UTC](https://discourse.vtk.org/t/implementing-crosshair-movement-on-mouse-click-in-mpr-viewer-using-vtlreslicecursorwidget/12770/6 "2023-11-22T11:51:42Z")

</div>

Thank you for pointing me in the right direction. I’m eager to proceed with implementing the “jump to mouse position” feature using the vtlResliceCursorWidget. To ensure I make the necessary modifications correctly, could you please provide more context or guidance on the following for better understanding?

---

<div class="post-metadata">

### Author: ![wulicheng](https://discourse.vtk.org/user_avatar/discourse.vtk.org/wulicheng/32/1990_2.png) [@wulicheng](https://discourse.vtk.org/u/wulicheng)
#### Post date: [April 11, 2024, 2:34am UTC](https://discourse.vtk.org/t/implementing-crosshair-movement-on-mouse-click-in-mpr-viewer-using-vtlreslicecursorwidget/12770/7 "2024-04-11T02:34:57Z")

</div>

this is a js example ,do you know some cpp examples as the sample.
