How do I disable Zoom and Pan in the post action callback?

20 views (last 30 days)
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 

Accepted Answer

MathWorks Support Team
MathWorks Support Team on 3 Sep 2015
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';

More Answers (0)

Categories

Find more on Visual Exploration in Help Center and File Exchange

Products


Release

R2015a

Community Treasure Hunt

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

Start Hunting!