Need help for Zoom function in AppDesigner

조회 수: 2 (최근 30일)
Umair Mughal
Umair Mughal 2020년 6월 2일
답변: Deepak 2024년 11월 5일
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.

답변 (1개)

Deepak
Deepak 2024년 11월 5일
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.

카테고리

Help CenterFile Exchange에서 Data Exploration에 대해 자세히 알아보기

제품


릴리스

R2020a

Community Treasure Hunt

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

Start Hunting!

Translated by