Be the first to rate this file! 24 Downloads (last 30 days) File Size: 5.66 KB File ID: #31902
image thumbnail

ButtonGroup Objects

by Matthew Whitaker

 

21 Jun 2011

Container objects to manage radio or toggle buttons with functionality of the GUI Layout Toolbox

| Watch this File

File Information
Description

The ButtonGroup controls require the GUI Layout Toolbox by Ben Tordoff and David
Sampson available at:
http://www.mathworks.com/matlabcentral/fileexchange/27758-gui-layout-toolbox
The controls in this submissionshould be placed in the +uiextras folder in the GUI Layout Toolbox or in another folder called +uiextras that resides under a folder on your path. It is recommended to run rehash path after doing this.

EXample:
function buttonGroupExample
    f = figure;
    vb = uiextras.VBox('Parent',f,'Units','Normalized');
    bgH = uiextras.HButtonGroup('Parent',vb,'Buttons',{'1','2','3'},'Spacing',50,'Padding',10,'SelectedChild',1,'SelectionChangeFcn',@onSelectionChange);
    hb = uiextras.HBox('Parent',vb);
    bgV = uiextras.VButtonGroup('Parent',hb,'ButtonStyle','toggle','Buttons',('123')','Spacing',20,'Padding',10,'SelectedChild',3,'SelectionChangeFcn',@onSelectionChange);
    p = uiextras.Panel('Parent',hb);
    set(hb,'Sizes',[100,-1]);
    lblDisplay = uicontrol('Parent',p,'FontSize',16,'Style','text');
    onSelectionChange([],[]);
    function onSelectionChange(src,evt)
        disp(evt);
        set(lblDisplay,'String',int2str([bgH.SelectedChild,bgV.SelectedChild]));
    end %onSelectionChange
end %buttonGroupExample

Acknowledgements

The author wishes to acknowledge the following in the creation of this submission:
GUI Layout Toolbox

MATLAB release MATLAB 7.12 (2011a)
Tags for This File  
Everyone's Tags
Tags I've Applied
Add New Tags Please login to tag files.
Comments and Ratings (1)
13 Jul 2011 Henry Harrison

Thanks for this, Matthew. One question though. There may be an issue with maintaining the 'Enable' setting of the children. In my GUI I have a toolbar, and some tools are only available in certain situations. Setting the children's 'Enable' state works fine, until I select a tool, at which point all disabed buttons become enabled.

There is an easy workaround, of course, to re-disable the disabled buttons at the end of the callback function. However I though I would bring the issue to your attention.

Please login to add a comment or rating.
Tag Activity for this File
Tag Applied By Date/Time
uibuttongroup Matthew Whitaker 22 Jun 2011 09:10:28
layouts Matthew Whitaker 22 Jun 2011 09:10:28
gui Matthew Whitaker 22 Jun 2011 09:10:28

Contact us at files@mathworks.com