ancestor
Ancestor of graphics object
Syntax
p = ancestor(h,type)
p = ancestor(h,type,'toplevel')
Description
p = ancestor(h,type)
returns the handle of the closest ancestor ofh
, if the ancestor is one of the types of graphics objects specified bytype
.type
can be:
a character vector with the name of a single type of object, for example,
'figure'
.a cell array containing the names of multiple objects, for example,
{'hgtransform','hggroup','axes'}
.
If MATLAB®cannot find an ancestor ofh
that is one of the specified types, thenancestor
returnsp
as empty. Whenancestor
searches the hierarchy, it includes the object itself in the search. Therefore, if the object with handleh
is of one of the types listed intype
,ancestor
will return objecth
.
ancestor
returnsp
as empty but does not issue an error ifh
is not a graphics object.
p = ancestor(h,type,'toplevel')
returns the highest-level ancestor ofh
,如果这类型中出现type
argument.