How do I disable Zoom and Pan in the post action callback?
12 次查看(过去 30 天)
显示 更早的评论
MathWorks Support Team
2009-6-27
编辑: MathWorks Support Team
2015-9-3
When I try to set the zoom or pan objects to off in the post action callback, MATLAB generates an error. The post action callback is structured in the following way:
For zoom:
function myzoompostcallback(obj,evd)
hZ = zoom(obj);
%turn zoom off
set(hZ,'Enable','off');
This callback creates the following error:
Warning: An error occurred during the mode callback.
> In uitools.uimode.fireActionPostCallback at 14
In zoom>localApplyZoomFactor at 1582
In zoom>local2DButtonUpFcn at 1121
In hgfeval at 63
In uitools.uimode.modeWindowButtonUpFcn at 27
In uitools.uimode.setCallbackFcn>localModeWindowButtonUpFcn at 34
For pan:
function mypanpostcallback(obj,evd)
hP = pan(obj);
%turn pan off
set(hP,'Enable','off');
This callback creates the following error:
Warning: An error occurred during the mode callback.
> In uitools.uimode.fireActionPostCallback at 14
In pan>locWindowButtonUpFcn at 496
In hgfeval at 63
In uitools.uimode.modeWindowButtonUpFcn at 53
In uitools.uimode.modeControl>localModeWindowButtonUpFcn at 155
采纳的回答
MathWorks Support Team
2015-9-3
To enable the ability to turn off pan or zoom in the post action callback, you must set the "ModeHandle" 's "Blocking" property to false. This feature is undocumented and is not even visible when the property 'hideundocumented' is set to 'off'.
For "zoom": Use the following code in the post action callback to turn off the zoom using the set function:
function myzoompostcallback(obj,evd)
%obtain zoom object from figure
hZ = zoom(obj);
%turn blocking off to allow setting the zoom state (true by default)
hM = hZ.ModeHandle;
set(hM,'Blocking',false);
%turn zoom off
set(hZ,'Enable','off');
Use the following code in the post action callback to turn off the zoom using dot notation:
function myzoompostcallback(obj,evd)
hZ = zoom(obj);
hZ.ModeHandles.Blocking = false;
hZ.Enable = 'off';
For "pan":
Use the following code in the post action callback to turn off the pan using the set function:
function mypanpostcallback(obj,evd)
%obtain pan object from figure
hP = pan(obj);
%turn blocking off to allow setting the pan state (true by default)
hM = hP.ModeHandle;
set(hM,'Blocking',false);
%turn pan off
set(hP,'Enable','off');
Use the following code in the post action callback to turn off the pan using dot notation:
function mypanpostcallback(obj,evd)
hP = pan(obj);
hP.ModeHandles.Blocking = false;
hP.Enable = 'off';
0 个评论
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Visual Exploration 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!