Page 1 of 1

--Using ActionGroup

PostPosted: Thu Feb 04, 2016 11:44 am
by Development@SIB


This article is outdated - please use our new system at

https://doc.sibvisions.com




If you have multiple radio/toggle buttons in your UI and have the use-case that only one button should be selected than the ActionGroup is a perfect match. The ActionGroup handles a set of radio/toggle buttons and ensures that only one button in the group is selected.

The ActionGroup has an action event that triggers notifications when the selection has been changed.
Syntax: [ Download ] [ Hide ]
UIRadioButton butHLeft = new UIRadioButton("Left");
UIRadioButton butHCenter = new UIRadioButton("Center");
UIRadioButton butHRight = new UIRadioButton("Right");
UIRadioButton butHStretch = new UIRadioButton("Stretch");
             
ActionGroup buttonGroup = new ActionGroup(butHLeft, butHCenter, butHRight, butHStretch);


The selected button can be changed programmatically by index
Syntax: [ Download ] [ Hide ]
buttonGroup.setSelectedIndex(1); // Choose the selected index
or by button
Syntax: [ Download ] [ Hide ]
buttonGroup.setSelectedButton(butHLeft); // Choose the selected button


Use eventAction to get notifications about selection changes:

Syntax: [ Download ] [ Hide ]
buttonGroup.eventAction().addListener(this, “doSelectionChanged”);