Need help for Zoom function in AppDesigner

8 views (last 30 days)
Umair Mughal
Umair Mughal on 2 Jun 2020
Answered: Deepak on 5 Nov 2024 at 10:40
I know, the zoom for UIAxes only works like zoom(app.UIAxes, 'on'/'off'); I want to use a function (@updateDateLabel) after zoom operaion is performed. So, the only way to this is by using z = zoom(UIFigure), and in AppDesigner it's not working.
z = zoom(figH);
p = pan(figH);
d = datacursormode(figH);
set(z,'ActionPostCallback',@updateDateLabel);
set(p,'ActionPostCallback',@updateDateLabel);
set(d,'UpdateFcn',@dateTip);
Same is the case for pan.

Answers (1)

Deepak
Deepak on 5 Nov 2024 at 10:40
In App designer, handling events like pan and zoom can be a bit different from working with traditional figure windows. The zoom and pan functions do not support the traditional callbacks directly, so we can use “ActionPostCallback” property to define callback to these functions. This way, we can call the “updateDateLabel” function post callback of zoom and pan objects.
Here is the App Designer code to achieve the same:
figH = app.UIFigure;
% Create zoom and pan objects
z = zoom(figH);
p = pan(figH);
% Set the ActionPostCallback for zoom and pan
set(z, 'ActionPostCallback', @(src, event) updateDateLabel(app, src, event));
set(p, 'ActionPostCallback', @(src, event) updateDateLabel(app, src, event));
% Define your updateDateLabel function within the app
methods (Access = private)
function updateDateLabel(app, src, event)
% Your custom function code here
disp('Zoom or pan action completed');
% Update your UI components or perform other actions
end
end
Please find attached the documentation of App Designer Callbacks for reference:
I hope this assists in resolving the issue.

Categories

Find more on Data Exploration in Help Center and File Exchange

Products


Release

R2020a

Community Treasure Hunt

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

Start Hunting!