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

%   Copyright (c) 1984-98 by The MathWorks, Inc.
%   $Revision: 1.7 $  $Date: 1997/12/06 00:41:32 $
%   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

