How to get WindowButtonMotionFcn to track mouse position
30 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
NICOLA REVELIN
el 9 de En. de 2021
Comentada: Naum Derzhi
el 9 de Jun. de 2021
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.
0 comentarios
Respuesta aceptada
Mario Malic
el 10 de En. de 2021
Here's the question that'll help you, there are more two relevant answers to it. Link
7 comentarios
Naum Derzhi
el 9 de Jun. de 2021
WIndowButtonMotion event is generated by the figure, and you need to attach your callback to the figure. You can determine to which figure your axes belongs, checking the object hierarchy. Keep in mind, that axes's parent may be something other than the figure, and you need to move up the object hierarchy until to get to the figure parent (where Type is 'Figure'). In the callback attached to this event you can interrogate all axes children of this window to find out within which axes the cursor was at the time of the event (compare the axes.CurrentPoint to axes limits). Keep in mind, if there are things other than axis in the window, it may happen that the cursor was outside all of them at the time of the event.
Más respuestas (0)
Ver también
Categorías
Más información sobre Interactive Control and Callbacks en Help Center y File Exchange.
Productos
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!