function B = subsref(A,S)
%SCRIBEHGOBJ/SUBSREF

%   Copyright 1984-2000 The MathWorks, Inc. 
%   $Revision: 1.8 $  $Date: 2000/06/01 02:53:00 $
%   J.H. Roh & B.A. Jones 4-25-97.


for idx = 1:length(S)
   switch S(idx).type
   case '.'
      if length(A)==1
         switch S(idx).subs
         case 'HGHandle'
            B = A.HGHandle;
         case 'IsSelected'
            B = A.ObjSelected;
         otherwise
            B = get(A,S(idx).subs);
         end
      else
         B = {};
         for a=[A{:}]
            B{end+1}=subsref(a,S(idx));
         end
      end
   case {'()' '{}'}
      structA = struct(A);
      B = structA(S(idx).subs{:});
      B = class(B,'scribehgobj');
   end
   A = B;
end

