view private/addkbcallback.m @ 15:a6d5597bd922

Trying alternative fixed point computation in mc_global_info1>mc_fixpt2; Also factored out randnat from some other functions.
author samer
date Mon, 27 Feb 2012 14:41:24 +0000
parents 0e0f2805ef9c
children
line wrap: on
line source
function addkbcallback(fig,handler)
% addkbcallback - Add keypress handler to figure or remove all handlers

	if nargin>1,
		cb=get(fig,'KeypressFcn');
		if isempty(cb)
			set(fig,'KeypressFcn',{@kpcb,{handler}});
		else
			set(fig,'KeypressFcn',{cb{1},[cb{2},{handler}]});
		end
	else
		set(fig,'KeypressFcn',[]);
	end
end

function kpcb(a,b,handlers), 
	for i=1:length(handlers), h=handlers{i}; h(b); end; 
end