function fig = gcbf
%GCBF Get handle to current callback figure.
%   FIG = GCBF returns the handle of the figure that contains the
%   object whose callback is currently executing.  If the current 
%   callback object is the figure, the figure is returned.
%
%   When no callbacks are executing, GCBF returns [].
%
%   The return value of GCBF is identical to the FIGURE
%   output argument of GCBO.
%
%   See also GCBO, GCO, GCF, GCA.

%   Copyright (c) 1984-98 by The MathWorks, Inc.
%   $Revision: 1.5 $  $Date: 1997/11/21 23:34:36 $

object = get(0, 'CallbackObject');

if isempty(object),
  fig=[];
elseif object == 0,
  fig = [];
else,
  fig = object;
  while get(fig,'parent') ~=0,
    fig = get(fig,'parent');
  end
end

