MATLAB: Get(axes,’CurrentPoint’) : stack on not-updated current point

axescallbackcurrentpointcursorginputguiinteractioninterfacemakerMATLABmousepointerlocationposition;readuserwindowbuttonmotionfcnwindowbuttonupfcn

CurrentPoint definition:
Location of last button click in this Figure. MATLAB sets this property to the location of the pointer at the time of the most recent mouse button press. MATLAB updates this property whenever you press the mouse button while the pointer is in the Figure window.
In addition, MATLAB updates CurrentPoint before executing callback routines defined for the Figure WindowButtonMotionFcn and WindowButtonUpFcn properties. This enables you to query CurrentPoint from these callback routines.
PROBLEM:
This is the first time I'm trying to use CurrentPoint without a previous click or inside a WindowButtonMotionFcn. And as per definition, the output is relative to the last click on the axes, and not the actual current position. I have wasted 2 hours looking for a solution and this thing is driving me mad. One way could be to calculate manually from groot 'PointerLocation', but having a couple of parent panels makes the calculation a bit off the one provided by CurrentPoint. In addition, if the axes is reversed or rotated somehow, it only gets more difficult. Another way would be to call a java.awt.robot to simulate a click…but looks dirty to me.
What I am looking for is either a direct clean solution to it, or at least a way of firing some hidden events and make matlab update the CurrentPoint property.
Thank you for the support

Best Answer

Hello Yury,
If you check out this answer, it answers your question. The documentation (R2018a link)backs it up as well. If you define a WindowButtonMotionFcn callback, the CurrentPoint property of the axes should update with the current position of the mouse cursor. You should be able to either update some other property with the current point within the callback, or just access the current point from wherever necessary.
-Cam