libgdx API

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

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

public class ButtonGroup
extends java.lang.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)
           
protected  boolean canCheck(Button button, boolean newState)
          Called when a button is checked or unchecked.
 Array<Button> getAllChecked()
           
 Array<Button> getButtons()
           
 Button getChecked()
           
 void remove(Button... buttons)
           
 void remove(Button button)
           
 void setChecked(java.lang.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
clone, equals, finalize, 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(java.lang.String text)
Sets the first TextButton with the specified text to checked.


canCheck

protected boolean canCheck(Button button,
                           boolean newState)
Called when a button is checked or unchecked.

Returns:
true if the new state should be allowed.

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.


libgdx API

Copyright 2010 Mario Zechner (contact@badlogicgames.com), Nathan Sweet (admin@esotericsoftware.com)