function button=get_but(f)

% function button=get_but(f)
%
% This function is used in conjunction with FD3.   Get_but returns the number
% of the last button (1, 2, or 3) pressed in the figure window 'f'.
%
% JWD

% Note that either the manual or the program is wrong. The manual
% says button2=ext, button3=alt, but Matlab returns button2=alt, button3=ext.

mbtype=get(f,'SelectionType');
if mbtype(1:3)=='nor'
   button=1;
elseif mbtype(1:3)=='alt'
   button=2;
elseif mbtype(1:3)=='ext'
   button=3;
elseif mbtype(1:3)=='ope'
   button=4;   % this actually means a double click
else
   button=0;   %unknown button type
end
