フィルターのクリア

WindowButtonMotionFcn cannot be changed in later time

7 ビュー (過去 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 Center および File ExchangeVisual Exploration についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by