com.badlogic.gdx.scenes.scene2d.ui
Class ButtonGroup

java.lang.Object
  extended by com.badlogic.gdx.scenes.scene2d.ui.ButtonGroup

public class ButtonGroup
extends Object

Manages a group of buttons to enforce a minimum and maximum number of checked buttons. This enables "radio button" functionality and more. A button may only be in one group at a time.

Author:
Nathan Sweet

Constructor Summary
ButtonGroup()
           
ButtonGroup(Button... buttons)
           
 
Method Summary
 void add(Button... buttons)
           
 void add(Button button)
           
 Array<Button> getAllChecked()
           
 Array<Button> getButtons()
           
 Button getChecked()
           
 void remove(Button... buttons)
           
 void remove(Button button)
           
 void setChecked(String text)
          Sets the first TextButton with the specified text to checked.
 void setMaxCheckCount(int maxCheckCount)
          Sets the maximum number of buttons that can be checked.
 void setMinCheckCount(int minCheckCount)
          Sets the minimum number of buttons that must be checked.
 void setUncheckLast(boolean uncheckLast)
          If true, when the maximum number of buttons are checked and an additional button is checked, the last button to be checked is unchecked so that the maximum is not exceeded.
 void uncheckAll()
          Sets all buttons' Button.isChecked() to false, regardless of setMinCheckCount(int).
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ButtonGroup

public ButtonGroup()

ButtonGroup

public ButtonGroup(Button... buttons)
Method Detail

add

public void add(Button button)

add

public void add(Button... buttons)

remove

public void remove(Button button)

remove

public void remove(Button... buttons)

setChecked

public void setChecked(String text)
Sets the first TextButton with the specified text to checked.


uncheckAll

public void uncheckAll()
Sets all buttons' Button.isChecked() to false, regardless of setMinCheckCount(int).


getChecked

public Button getChecked()
Returns:
the first checked button, or null.

getAllChecked

public Array<Button> getAllChecked()

getButtons

public Array<Button> getButtons()

setMinCheckCount

public void setMinCheckCount(int minCheckCount)
Sets the minimum number of buttons that must be checked. Default is 1.


setMaxCheckCount

public void setMaxCheckCount(int maxCheckCount)
Sets the maximum number of buttons that can be checked. Set to -1 for no maximum. Default is 1.


setUncheckLast

public void setUncheckLast(boolean uncheckLast)
If true, when the maximum number of buttons are checked and an additional button is checked, the last button to be checked is unchecked so that the maximum is not exceeded. If false, additional buttons beyond the maximum are not allowed to be checked. Default is true.



Copyright © 2013. All Rights Reserved.