MATLAB: Does overlapping panels in GUIDE seem to lock their ‘visible’ property in MATLAB 7.9 (R2009b)

MATLABuibuttongroupuipanel

I lay out a GUI with GUIDE and I want to overlap two button group panels, because I don't have enough space to have them separately. I then want to toggle between them by setting only one to be visible at a time.
However, I find that if I set the 'visible' property to 'off' the other also disappears, despite the other having 'visible' set to 'on'.

Best Answer

GUIDE will make any UI component, which is positioned within or over a panel, a child of that panel. This includes other panels.
Thus, the above behavior is expected because, when a panel's visibility is set to 'off', any components that are a child of that panel should also not be visible.
The solution is to make sure that your panels are all direct children of the figure window, rather than nested within each other. You can do this with additional code in the Opening Function. For example, you could add similar code to this:
% Ensure uipanels are parented by the figure
panel_handles = findobj(handles.figure1,'type','uipanel')
set( panel_handles, 'parent', handles.figure1)