How do I disable Zoom and Pan in the post action callback?
19 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
MathWorks Support Team
le 27 Juin 2009
Modifié(e) : MathWorks Support Team
le 3 Sep 2015
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
Réponse acceptée
MathWorks Support Team
le 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';
0 commentaires
Plus de réponses (0)
Voir également
Catégories
En savoir plus sur Visual Exploration dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!