# How to pick a point closest from the mouse cursor?

**URL:** https://discourse.vtk.org/t/how-to-pick-a-point-closest-from-the-mouse-cursor/4318
**Category:** Support
**Created:** [September 29, 2020, 2:59am UTC](https://discourse.vtk.org/t/how-to-pick-a-point-closest-from-the-mouse-cursor/4318 "2020-09-29T02:59:26Z")
**Posts on this page:** 1
**Showing post:** 3

<div class="post-metadata">

### Author: ![Kim\_William](https://discourse.vtk.org/user_avatar/discourse.vtk.org/kim_william/32/373_2.png) [@Kim\_William](https://discourse.vtk.org/u/Kim_William)
#### Post date: [October 5, 2020, 12:36am UTC](https://discourse.vtk.org/t/how-to-pick-a-point-closest-from-the-mouse-cursor/4318/3 "2020-10-05T00:36:30Z")

</div>

Hi, Paulo.  
Thank you for your help.  
But I have an additional question…

Do I need a preparation step to use the vtkPointLocator?

I have written the code that picking a point from the GetEventPosition() function on OnMouseMove() event.

I referred to the following examples:  
[https://lorensen.github.io/VTKExamples/site/Cxx/Interaction/Picking/](https://lorensen.github.io/VTKExamples/site/Cxx/Interaction/Picking/)  
[https://lorensen.github.io/VTKExamples/site/Cxx/Interaction/PointPicker/](https://lorensen.github.io/VTKExamples/site/Cxx/Interaction/PointPicker/)

I added the vtkPointLocator and call the FindClosestPoint() function, but it always returns -1.  
I referred to the following examples:  
[https://lorensen.github.io/VTKExamples/site/Cxx/PolyData/PointLocator/](https://lorensen.github.io/VTKExamples/site/Cxx/PolyData/PointLocator/)  
[https://lorensen.github.io/VTKExamples/site/Cxx/PolyData/PointLocatorVisualization/](https://lorensen.github.io/VTKExamples/site/Cxx/PolyData/PointLocatorVisualization/)

Could you please advise for me?

Thank you.

Best regards,  
William Kim

---

_[View the full topic](https://discourse.vtk.org/t/how-to-pick-a-point-closest-from-the-mouse-cursor/4318)._
