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

18 ビュー (過去 30 日間)
MathWorks Support Team
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
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 件)

カテゴリ

Help Center および File ExchangeVisual Exploration についてさらに検索

製品


リリース

R2015a

Community Treasure Hunt

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

Start Hunting!

Translated by