WindowButtonMotionFcn cannot be changed in later time

5 次查看(过去 30 天)
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