Checkboxes disappear when a new one created (matlab 2007b)

1 view (last 30 days)
I have a button group with handle handles.dataSelect and I'm trying to add some texts and checkboxes to that group based on information contained in handles.dataStruct. I would expect the output to be something like
Channel Select
[] Channel 1
[] Channel 2
Temperature Select
[] T = 20 K
[] T = 40 K
However, what I see instead is
Channel Select
... lots of space ...
[] Last channel
Temperature Select
... lots of space ...
[] Last temperature
I checked and the button group does have all of the checkboxes as children and all children ARE in fact set to be visible and enabled.
However, I don't see any but the last channel and the last temperature. When I debugged, with every for loop iteration the previous checkbox disappeared from view while the new checkbox was added...
It seems like some simple mistake on my part, but I can't quite figure out what exactly I did wrong. Any help would be appreciated, the exact code I used is below.
Thank you,
function createView( handles )
'Tag','ChSelectText','String','Channel Select','Units','normalized',...
'HorizontalAlignment','left','Position',[0.1, chPos, 0.6, .2]);
for j=1:length(handles.dataStruct.channels),
'Style','checkbox','Tag',['Ch' num2str(j) 'box'],'String',...
['Channel ' num2str(handles.dataStruct.channels(j))],...
'Position',[0.1, chPos-j*0.06, 0.6, .2]);
'Tag','TempSelectText','String','Temperature Select',...
[0.1, tempPos, 0.6, .2]);
for j=1:length(handles.dataStruct.temps),
'Style','checkbox','Tag',['Temp' num2str(j) 'box'],'String',...
['T = ' num2str(handles.dataStruct.temps(j)) ' K'],...
'Position',[0.1, tempPos-j*0.06, 0.6, .2]);
guidata(handles.dataSelect, handles);

Accepted Answer

Matt Fig
Matt Fig on 2 Mar 2011
You are overlapping each with the next. (This is why I prefer to work in pixels by the way.)
For starters, change:
[0.1, chPos-j*0.06, 0.6, .2]
[0.1, chPos-j*0.06, 0.6, .1]
in the first FOR loop. You will have to play around with the numbers to get them correct and look like what you want.
  1 Comment
Ilya Valmianski
Ilya Valmianski on 2 Mar 2011
You sir, are quite right! Didn't know it would disable the view of one of them if I did it!

Sign in to comment.

More Answers (0)

Community Treasure Hunt

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

Start Hunting!