WindowButtonMotionFcn cannot be changed in later time

조회 수: 5 (최근 30일)
raym
raym 2023년 4월 10일
답변: raym 2023년 4월 10일
Hi, I am creating a figure and customize the pan-function:
function hFig = mouse_figure
...
hFig = figure;
set(hFig,...
'WindowButtonDownFcn' , @pan_click,...
'WindowButtonUpFcn' , @pan_release,...
'WindowButtonMotionFcn', @pan_motion);
...
end
Then in the caller workspace, I need to update the WindowButtonMotionFcn to a new function that incorporate more arguments and do more stuffs. However, after the figure was shown, I found that the WindowButtonMotionFcn was not called as expected. Instead, it is still calling the original pan_motion. Is there something wrong with the code?
function f = test
f = mouse_figure;
% debug here, get that:
% WindowButtonDownFcn: @mouse_figure/pan_click
% WindowButtonMotionFcn: @mouse_figure/pan_motion
% WindowButtonUpFcn: @mouse_figure/pan_release
plot([1,2],[3,4])
zoom yon
% debug here, get that:
% WindowButtonDownFcn: {3x1 cell}
% WindowButtonMotionFcn: @mouse_figure/pan_motion
% WindowButtonUpFcn: {3x1 cell}
% f.WindowButtonDownFcn
% ans =
% @localModeWindowButtonDownFcn
% [1x1 matlab.uitools.internal.uimode]
% @(obj,evd)localWindowButtonDownFcn(obj,evd,hMode)
% f.WindowButtonUpFcn
% ans =
% @localModeWindowButtonUpFcn
% [1x1 matlab.uitools.internal.uimode]
% []
set(f,'WindowButtonMotionFcn', @(~,~) pan_motion_driftPatchTextObjs(f,panHor,panVer,aYTopTextPatchCollects,aXLeftTextPatchCollects));
% debug here, get that:
% WindowButtonDownFcn: {3x1 cell}
% WindowButtonMotionFcn: [function_handle]
% WindowButtonUpFcn: {3x1 cell}
% f.WindowButtonDownFcn
% ans =
% @localModeWindowButtonDownFcn
% [1x1 matlab.uitools.internal.uimode]
% @(obj,evd)localWindowButtonDownFcn(obj,evd,hMode)
% f.WindowButtonMotionFcn
% ans =
% @(~,~)pan_motion_driftPatchTextObjs(f,panHor,panVer,aYTopTextPatchCollects,aXLeftTextPatchCollects)
% f.WindowButtonUpFcn
% ans =
% @localModeWindowButtonUpFcn
% [1x1 matlab.uitools.internal.uimode]
% []
end
% after exit to base workspace:
a = ans;
a
% WindowButtonDownFcn: {3x1 cell}
% WindowButtonMotionFcn: @mouse_figure/pan_motion
% WindowButtonUpFcn: {3x1 cell}
% a.WindowButtonDownFcn
% ans =
% @localModeWindowButtonDownFcn
% [1x1 matlab.uitools.internal.uimode]
% @(obj,evd)locWindowButtonDownFcn(obj,evd,hMode)
% a.WindowButtonMotionFcn
% ans =
% @mouse_figure/pan_motion
% a.WindowButtonUpFcn
% ans =
% @localModeWindowButtonUpFcn
% [1x1 matlab.uitools.internal.uimode]
% []

채택된 답변

raym
raym 2023년 4월 10일
I found the reason:
zoom yon
this command modifies the pan callbacks into an temporary status, thus modification of pan callback when zoom is on is not stable.
After remove the command, it is OK now.

추가 답변 (0개)

카테고리

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

Community Treasure Hunt

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

Start Hunting!

Translated by