|
libgdx API | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.badlogic.gdx.scenes.scene2d.Actor
com.badlogic.gdx.scenes.scene2d.ui.Widget
com.badlogic.gdx.scenes.scene2d.ui.CheckBox
public class CheckBox
A checkbox with a label.
CheckBox.CheckedListener
with the CheckBox.
Widget.setPrefSize(int, int)
to programmatically change the size to your liking. Note that this will
not have an affect on the actual rendering, but only manipulate the hit area of the CheckBox.
Widget
displaying one of two TextureRegion
instances representing the checked
and unchecked state, as well as a label via a BitmapFont
and accompanying Color
. The style is defined via an
instance of CheckBox.CheckBoxStyle
, which can either be done programmatically or via a Skin
.
A CheckBox's style definition in a skin XML file should look like this:
<checkbox name="styleName"
checked="checkedRegion"
unchecked="uncheckedRegion"
font="fontName"
fontColor="fontColor"/>
name
attribute defines the name of the style which you can later use with
Skin#newCheckBox(String, String, String)
.checked
attribute references a TextureRegion
by name, to be used when the CheckBox is checkedunchecked
attribute references a TextureRegion
by name, to be used when the CheckBox is uncheckedfont
attribute references a BitmapFont
by name, to be used to render the labelfontColor
attribute references a Color
by name, to be used to render the label
Nested Class Summary | |
---|---|
static class |
CheckBox.CheckBoxStyle
Defines a check box style, see CheckBox |
static interface |
CheckBox.CheckedListener
Interface for listening to check events on this check box. |
Field Summary |
---|
Fields inherited from class com.badlogic.gdx.scenes.scene2d.ui.Widget |
---|
invalidated, prefHeight, prefWidth |
Fields inherited from class com.badlogic.gdx.scenes.scene2d.Actor |
---|
actions, color, height, name, originX, originY, parent, rotation, scaleX, scaleY, touchable, visible, width, x, y |
Constructor Summary | |
---|---|
CheckBox(java.lang.String text,
CheckBox.CheckBoxStyle style)
|
|
CheckBox(java.lang.String text,
Skin skin)
|
|
CheckBox(java.lang.String name,
java.lang.String text,
CheckBox.CheckBoxStyle style)
|
Method Summary | |
---|---|
void |
draw(SpriteBatch batch,
float parentAlpha)
Draws the Actor. |
Actor |
hit(float x,
float y)
|
boolean |
isChecked()
|
void |
layout()
Positions and sizes each child of this actor. |
void |
setChecked(boolean isChecked)
Sets whether this check box is checked or not. |
CheckBox |
setCheckedListener(CheckBox.CheckedListener listener)
Sets the CheckBox.CheckedListener |
void |
setStyle(CheckBox.CheckBoxStyle style)
Sets the style of this widget. |
boolean |
touchDown(float x,
float y,
int pointer)
|
void |
touchDragged(float x,
float y,
int pointer)
|
void |
touchUp(float x,
float y,
int pointer)
|
Methods inherited from class com.badlogic.gdx.scenes.scene2d.ui.Widget |
---|
getPrefHeight, getPrefWidth, invalidate, invalidateHierarchy, setPrefSize |
Methods inherited from class com.badlogic.gdx.scenes.scene2d.Actor |
---|
act, action, clearActions, isMarkedToRemove, keyDown, keyTyped, keyUp, markToRemove, remove, scrolled, toLocalCoordinates, toString, touchMoved |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Constructor Detail |
---|
public CheckBox(java.lang.String text, Skin skin)
public CheckBox(java.lang.String text, CheckBox.CheckBoxStyle style)
public CheckBox(java.lang.String name, java.lang.String text, CheckBox.CheckBoxStyle style)
Method Detail |
---|
public void setStyle(CheckBox.CheckBoxStyle style)
Widget.invalidateHierarchy()
internally.
style
- public void layout()
Layout
Layout.invalidate()
is
called.
public void draw(SpriteBatch batch, float parentAlpha)
Actor
FadeIn
and
other Actions to have an effect even if they are only set on the parent of the Actor.
draw
in class Actor
batch
- the spritebatch to render withparentAlpha
- the parent's alpha value.public boolean touchDown(float x, float y, int pointer)
touchDown
in class Actor
public void touchUp(float x, float y, int pointer)
touchUp
in class Actor
public void touchDragged(float x, float y, int pointer)
touchDragged
in class Actor
public Actor hit(float x, float y)
hit
in class Widget
public void setChecked(boolean isChecked)
isChecked
- checked or notpublic boolean isChecked()
public CheckBox setCheckedListener(CheckBox.CheckedListener listener)
CheckBox.CheckedListener
listener
- the listener or null
|
libgdx API | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |