The CurrentPoint property on UIAxes will always reflect the last click detected anywhere in the figure. That is how CurrentPoint has worked on regular axes for a long time, and how it has worked on UIAxes for as long as CurrentPoint has been supported on UIAxes. I just tested in a simple figure in R2019b and R2021a and that is the behavior I am seeing in both versions.
There was a limitation in R2019b that if you clicked within a panel (but not on a UIAxes) and on some other UI components, that click was not being detected, and therefore the CurrentPoint was not updated. If you clicked on the figure directly (not inside a panel or another container or component), those clicks would be detected and the CurrentPoint would be updated. This limitation was removed in R2020b, and I suspect that is why you are seeing this change in behavior in your app.
For example, in the picture below:
- If you click the green dot you should see the current point reflect [0.5 0.5]. This is what you were expecting.
- If you click the red dot you should see the current point reflect [0.1 -0.05]. Even though that dot is outside the axes, the current point will show you the place you clicked relative to the data values in the plot.
- If you click the blue dot you should see the current point reflect [1.2 0.5], for the same reason as the red dot.
- In R2019b, if you click anywhere in the yellow region, CurrentPoint will not be updated. This was a limitation in R2019b that has since been removed. In R2020b and later, if you click anywhere in the yellow region, CurrentPoint will be updated.
- In R2019b, R2021a, or any other release, clicking on the figure itself (the outer region outside the yellow region), CurrentPoint will be updated.
If your goal is to record the last point clicked, then you have a few options:
- Use the ButtonDownFcn on the axes (or UIAxes) itself. Starting in R2020b you can use the ButtonDownFcn on UIAxes (it did not work in R2020a or earlier releases). This callback will only fire when you click on the uiaxes/axes. To use this effectively, you may need to disable HitTest on objects in the axes. See Capturing Mouse Clicks for more details.
- Add a WindowButtonDownFcn to the figure, and when the callback fires (a) read the CurrentPoint property on the uiaxes/axes, (b) check if the CurrentPoint is within the axes limits, and if so (c) store the CurrentPoint somewhere for use later. Unlike ButtonDownFcn on the uaixes/axes, WindowButtonDownFcn on the figure will fire even if there are other objects in the axes that get in the way.
p1 = uipanel(f,'Position',[10 10 525 400],'BackgroundColor','yellow');
p2 = uipanel(p1,'Position',[25 25 475 350]);
f.WindowButtonDownFcn = @(~,~) disp(u.CurrentPoint(1,1:2));
s = scatter(u,[0.1 0.5 1.2],[-0.05 0.5 0.5],,eye(3),'filled');