function [h, hb] = gcoall(fig)
%GCOALL  Get Figure CurrentObject, including hidden handle objects

%   Copyright 1984-2000 The MathWorks, Inc. 
%   $Revision: 1.4 $  $Date: 2000/06/01 02:52:06 $

shh = get(0,'ShowHiddenHandles');
try
   if nargin==0
      fig = get(0,'CurrentFigure');
   end
   set(0,'ShowHiddenHandles','on');
   h = get(fig,'CurrentObject');
   if nargout==2
      hb = h;
   end
   % redirect to handler for grouped objects
   primaryObject = getappdata(h,'ScribeButtonDownHGObj');
   if ~isempty(primaryObject)
      h = primaryObject;
   end
   set(0,'ShowHiddenHandles',shh);
catch
   set(0,'ShowHiddenHandles',shh);
   h = [];
   if nargout==2
      hb = [];
   end
end