www.gusucode.com > mbcguitools 工具箱 matlab 源码程序 > mbcguitools/+mbcgui/+util/isShowing.m
function ret = isShowing(obj) %ISSHOWING Check whether a component is being displayed. % % RET = ISSHOWING(OBJ) checks whether OBJ and all of its ancestors up to % the figure are visible. If the object or any container has its Visible % property set to 'off' then the component is assumed to not be visible % on-screen and a false value is returned. % Copyright 2008-2015 The MathWorks, Inc. CurrentObj = obj; ret = false; FigureObj = ancestor(obj, 'figure'); if isgraphics(CurrentObj,'uitab') if CurrentObj==CurrentObj.Parent.SelectedTab CurrentObj = CurrentObj.Parent; else % tab not selected ret = false; return end end while strcmp(get(CurrentObj, 'Visible'), 'on') || isgraphics(CurrentObj, 'axes') if CurrentObj==FigureObj ret = true; return end CurrentObj = get(CurrentObj, 'Parent'); if isgraphics(CurrentObj,'uitab') if CurrentObj==CurrentObj.Parent.SelectedTab CurrentObj = CurrentObj.Parent; else % tab not selected ret = false; return end end end