www.gusucode.com > mbcguitools 工具箱 matlab 源码程序 > mbcguitools/@mbcmultiview/@ViewGroup/removeView.m

    function removeView(obj, hView)
%REMOVEVIEW Remove a ViewContainer from the ViewGroup
%
%  REMOVEVIEW(OBJ, HVIEW) removes the ViewContainer HVIEW from this
%  ViewGroup.  If HVIEW was the selected view, the selection will also be
%  changed to the first ViewContainer now listed in the ViewGroup.

%  Copyright 2005 The MathWorks, Inc. and Ford Global Technologies, Inc.


if ~isempty(obj.ViewContainers)
    [unused, idx] = intersect(obj.ViewContainers, hView);
    if ~isempty(idx)
        obj.ViewContainers(idx) = [];
        obj.ButtonDownListeners(idx) = [];
        obj.DestructionListeners(idx) = [];
        if ismember(obj.SelectedViewContainer, hView)
            % Need to change selected view
            obj.SelectedView = [];
            if ~isempty(obj.ViewContainers)
                obj.selectView(obj.ViewContainers(1));
            end
        end
    end
end