Cannot get zoom post-callback to work on UIAxes

I cannot get the zoom post-callback to work on UIAxes in app designer. The pre-callback works fine. Here is what I have which is embedded in the app startup function:
h = zoom(app.UIAxes);
h.ActionPreCallback = @myprecallback;
h.ActionPostCallback = @mypostcallback;
h.Enable = 'on';
function myprecallback(obj,evd)
disp('A zoom is about to occur.');
end
function mypostcallback(obj,evd)
disp('A zoom has occurred.');
end
I followed the example in the help and it works of course, but it is not on a UIAxes.

9 Comments

Works fine for me (r2020b).
What do you mean by, "cannot get [it] to work"? Is nothing appearing at all? Is there an error?
app.fig = uifigure();
app.UIAxes = uiaxes(app.fig);
h = zoom(app.UIAxes);
h.ActionPreCallback = @myprecallback;
h.ActionPostCallback = @mypostcallback;
h.Enable = 'on';
function myprecallback(obj,evd)
disp('A zoom is about to occur.');
end
function mypostcallback(obj,evd)
disp('A zoom has occurred.');
end
So if i use the zoom button icon, it will display "A zoom is about to occur.", but it will not zoom so it never displays "A zoom has occured." It does not throw an error, it just will not zoom. I have 2020a.
If I use my scroll wheel to zoom it does throw an error:
Unrecognized method, property, or field 'XRuler' for class 'matlab.ui.control.UIAxes'.
Error in matlab.graphics.interaction.internal.calculateOrigLimits
Error in matlab.graphics.interaction.internal.initializeView
Error in zoom>localStoreLimits (line 673)
matlab.graphics.interaction.internal.initializeView(hAxesList(i));
Error in zoom>localButtonWheelFcn (line 900)
localStoreLimits(hAxes(i));
Error in zoom>@(obj,evd)localButtonWheelFcn(obj,evd,hMode) (line 563)
set(hMode,'WindowScrollWheelFcn',@(obj,evd)localButtonWheelFcn(obj,evd,hMode));
Error using matlab.ui.internal.controller.FigureController/handleClientEvent (line 355)
Error while evaluating Figure WindowScrollWheelFcn.
I just tried the code you posted and it is now working either, maybe I need upgrade to 2020b?
That's useful information. Can you typically zoom in/out using the mouse and/or the toolbar options when you do not include these callbacks?
I don't have r2020a available right now but I might be able to check it later.
Do you have access to Matlab online? It's running r2020b and it also works well with the snippet of code in my comment.
Yes, it will work also if i use the pre-callback. The post-callback seems to hose it. I am downloading 2020b now.
It works in 2020b. Thanks, that saved me lots of headaches!!
The release notes do not mention ActionPostCallback. hmmm, I wonder what the problem was.
So my whole point of using a post-callback was to prevent user from using zoom to zoom out past my axis limits, and in 2020b it wont let them by default. So didnt neven need to set a post-callback!
I ended up not using it, super buggy. Especially if I customize the toolbar. Pan is also throwing errors.

Sign in to comment.

Answers (0)

Categories

Products

Release

R2020a

Asked:

on 14 Oct 2020

Commented:

on 14 Oct 2020

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!