Need help for Zoom function in AppDesigner
2 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
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.
0 Kommentare
Antworten (1)
Deepak
am 5 Nov. 2024
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.
0 Kommentare
Siehe auch
Kategorien
Mehr zu Data Exploration finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!