Delete function handle from callback list




iptremovecallback(h,callback,ID) deletes a callback from the list of callbacks created by imaddcallback for the object with handle h and the associated callback string callback. ID is the identifier of the callback to be deleted. This ID is returned by iptaddcallback when you add the function handle to the callback list.


Register three callbacks and try them interactively.

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 one of the callbacks and then move the mouse over the figure again. Whenever MATLAB® detects mouse motion over the figure, function handles f1 and f3 are called in that order.

iptremovecallback(h, 'WindowButtonMotionFcn', id2);
Was this topic helpful?