1

I have created an uipanel in Matlab and placed some uicontrols on it. How can I access those uicontrols when I copy the panel?

Example:

panel_a=uipanel(figure);
editfield=uicontrol(panel_a, 'style','edit');
x=uitab(tabgroup);
panel_b=copyobj(panel_a,x);

tmp=panel_b.editfield.String;      <-- how do I write this? 

How is editfield of panel_b accessed?

Suever
  • 64,497
  • 14
  • 82
  • 101
Emanrov
  • 37
  • 2
  • You either explicitly copy the edit box so it has a handle you specify or you parse the `'Children'` of `tmp` to find the handle to the copied object. – sco1 Sep 28 '16 at 15:38
  • there are a lot of uicontrols to access, copying each would be annoying. what do you mean by parsing the 'children' of tmp? – Emanrov Sep 28 '16 at 15:41

1 Answers1

1

If you assign the uicontrol a Tag value to begin with, you can use this to find the handle to it once you copy it to the new panel using findobj.

% Assign a 'Tag' value specific to this uicontrol
editfield = uicontrol(panel_a, 'style', 'edit', 'tag', 'editfield');

% Copy your relevant objects
panel_b = copyobj(panel_a, x);

% Use findobj to locate the handle to the object of interest
tmp = findobj(panel_b, 'Tag', 'editfield')

Alternately, you could use findobj to find all edit boxes

tmp = findobj(panel_b, 'Style', 'edit');
Suever
  • 64,497
  • 14
  • 82
  • 101