MATLAB: How to get WindowButtonMotionFcn to track mouse position

MATLABmatlab guitrack mousewindowbutton

Hello everyone,
I'm writing a GUI code in wich I basically need to track the position of the mouse in a UIAxes ,and then draw a veritcal line in this position, where some plot are already existing. I've seen in other questions that a WindowButtonMotionFcn could help me to do that but I'm not able to create it. I've also tried with a get(axes_handle,'CurrentPoint') but the problem comes out when I need to point right over a prevoius line for wich no output is given by the "get" function. Could anyone explain me how to get a WindowButtonMotionFcn or at least give me suggestion on how to track mouse position?
Thank you in advance for your help.

Best Answer

Here's the question that'll help you, there are more two relevant answers to it. Link