iptremovecallback
Delete function handle from callback list
Description
Examples
Add and Remove Callbacks from Figure
Add three callbacks to a figure and try them interactively. Whenever MATLAB®detects mouse motion over the figure, functionsf1
,f2
, andf3
are called in that order.
h = figure; f1 = @(varargin) disp('Callback 1'); f2 = @(varargin) disp('Callback 2'); f3 = @(varargin) disp('Callback 3'); id1 = iptaddcallback(h,'WindowButtonMotionFcn', f1); id2 = iptaddcallback(h,'WindowButtonMotionFcn', f2); id3 = iptaddcallback(h,'WindowButtonMotionFcn', f3);
Remove the callbackf2
. Move the mouse over the figure again. Whenever MATLAB detects mouse motion over the figure, only functionsf1
andf3
are called.
iptremovecallback(h,'WindowButtonMotionFcn',id2);