How to get parent name of a child GUI component?
10 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Khanh
el 20 de Oct. de 2014
Comentada: Khanh
el 21 de Oct. de 2014
Hi everybody,
I have a figure with 'Name' property: 'My figure' and 'Tag' property: 'figure1'.
In this figure, I have a push button with 'Name' property: 'Push me' and 'Tag' property: 'pushbutton1'
How can I get the push button's parent name in a programmatic GUI?
Is its parent name 'Myfigure' or 'figure1'?
% Code generated by FIG2M made by Thomas Montagnon (The MathWorks France)
% Great thanks to him
% --- FIGURE -------------------------------------
handles.figure1 = figure( ...
'Tag', 'figure1', ...
'Units', 'characters', ...
'Position', [102.8 24.3076923076923 114 32.9230769230769], ...
'Name', 'figure1', ...
'MenuBar', 'none', ...
'NumberTitle', 'off', ...
'Color', [0.941 0.941 0.941]);
% --- PUSHBUTTONS -------------------------------------
handles.pushbutton6 = uicontrol( ...
'Parent', handles.figure1, ...
'Tag', 'pushbutton6', ...
'Style', 'pushbutton', ...
'Units', 'characters', ...
'Position', [13.4 22.9230769230769 24.4 1.92307692307692], ...
'String', 'Push Button');
a=get(handles.pushbutton6,'parent') % a is a double, I don't know how to get parent name from it.
0 comentarios
Respuesta aceptada
Orion
el 20 de Oct. de 2014
Hi,
Actually, more than a double, a is a handle. (try ishandle(a))
In your case, with
a=get(handles.pushbutton6,'parent')
a is the handle of the parent of handles.pushbutton6, which here is the figure.
And to get the name of this (which usually is different of the tag) :
get(a,'Name')
ans =
figure1
Más respuestas (0)
Ver también
Categorías
Más información sobre Interactive Control and Callbacks en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!