function ret = isUIComponentInUIFigure(hObj)
% This undocumented function may be removed in a future release.
%
% Returns true if the object isa or is parented to a uicomponent in a uifigure

%   Copyright 2020 The MathWorks, Inc.

ret = false;
hFig = ancestor(hObj,'figure');
if matlab.ui.internal.isUIFigure(hFig)  
    c1 = ancestor(hFig, 'matlab.ui.container.CanvasContainer');
    c2 = ancestor(hObj, 'matlab.ui.container.CanvasContainer');
    ret = c1 ~= c2;
end
end

