Why does findobj not work with annotation tags?

2 vues (au cours des 30 derniers jours)
yosey
yosey le 23 Mar 2013
When I create an annotation with a Tag and use findobj the result is empty.
an = annotation('textbox',[0 0 1 1],'string','Hallo','Tag','annotation');
findobj('Tag','annotation')
  1 commentaire
Walter Roberson
Walter Roberson le 23 Mar 2013
Is it possible that the handle is hidden ?

Connectez-vous pour commenter.

Réponse acceptée

per isakson
per isakson le 24 Mar 2013
Modifié(e) : per isakson le 24 Mar 2013
findall returns the hg-handle. However, I find it strange that findobj fails, since HandleVisibility is on (by default). Matlab seems to behave this way and documentation is hard to read.
>> an = annotation('textbox',[0 0 1 1],'string','Hello','Tag','annotation');
>> h1 = findobj('Tag','annotation')
h1 =
Empty matrix: 0-by-1
>> h2 = findall(0,'Tag','annotation')
h2 =
178.0016
>> get( h2, 'HandleVis' )
ans =
on
>>
With R2012a,64bit,Win7
.
@Walter
Yes, an and h2 seems to be the same
....
>> [an,h2]
ans =
178.0024 178.0024
>> get( [an,h2], 'type' )
ans =
'hggroup'
'hggroup'
>> get( [an,h2], 'tag' )
ans =
'annotation'
'annotation'
>>
However, you spotted the cause
>> axh = get( h2, 'parent' )
axh =
173.0024
>> get( axh, 'HandleVis' )
ans =
off
annotation returns the handle of a hggroup, which is the child of an axes the HandleVisibility of which is off.
  2 commentaires
Walter Roberson
Walter Roberson le 24 Mar 2013
but is h2 the same as "an" ?
If the object that got tagged got created as a child of something with an invisible handle, what you describe would be the result.
yosey
yosey le 24 Mar 2013
Thank you both.

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur Graphics Object Programming dans Help Center et File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by