|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object com.badlogic.gdx.scenes.scene2d.Actor com.badlogic.gdx.scenes.scene2d.Group com.badlogic.gdx.scenes.scene2d.ui.WidgetGroup com.badlogic.gdx.scenes.scene2d.ui.Table com.badlogic.gdx.scenes.scene2d.ui.Button
public class Button
A button is a Table
with a checked state and additional style
fields for pressed, unpressed, and
checked. Each time a button is clicked, the checked state is toggled. Being a table, a button can contain any other actors.
ChangeListener.ChangeEvent
is fired when the button is clicked. Cancelling the event will restore the checked button state to what is
was previously.
The preferred size of the button is determined by the background and the button contents.
Nested Class Summary | |
---|---|
static class |
Button.ButtonStyle
The style for a button, see Button . |
Constructor Summary | |
---|---|
Button()
Creates a button without setting the style or size. |
|
Button(Actor child,
Button.ButtonStyle style)
|
|
Button(Actor child,
Skin skin)
|
|
Button(Actor child,
Skin skin,
String styleName)
|
|
Button(Button.ButtonStyle style)
|
|
Button(Drawable up)
|
|
Button(Drawable up,
Drawable down)
|
|
Button(Drawable up,
Drawable down,
Drawable checked)
|
|
Button(Skin skin)
|
|
Button(Skin skin,
String styleName)
|
Method Summary | |
---|---|
void |
draw(Batch batch,
float parentAlpha)
If this method is overridden, the super method or WidgetGroup.validate() should be called to ensure the widget group is laid
out. |
ClickListener |
getClickListener()
|
float |
getMinHeight()
|
float |
getMinWidth()
|
float |
getPrefHeight()
|
float |
getPrefWidth()
|
Button.ButtonStyle |
getStyle()
Returns the button's style. |
boolean |
isChecked()
|
boolean |
isDisabled()
|
boolean |
isOver()
|
boolean |
isPressed()
|
void |
setChecked(boolean isChecked)
|
void |
setDisabled(boolean isDisabled)
When true, the button will not toggle isChecked() when clicked and will not fire a ChangeListener.ChangeEvent . |
void |
setStyle(Button.ButtonStyle style)
|
void |
toggle()
Toggles the checked state. |
Methods inherited from class com.badlogic.gdx.scenes.scene2d.ui.Table |
---|
add, add, add, add, add, add, add, align, background, background, bottom, center, clearChildren, columnDefaults, debug, debug, debugCell, debugTable, debugWidget, defaults, drawDebug, getAlign, getBackground, getCell, getCells, getClip, getDebug, getPadBottom, getPadBottomValue, getPadLeft, getPadLeftValue, getPadRight, getPadRightValue, getPadTop, getPadTopValue, getPadX, getPadY, getRow, hit, invalidate, layout, left, pad, pad, pad, pad, padBottom, padBottom, padLeft, padLeft, padRight, padRight, padTop, padTop, removeActor, reset, right, row, setBackground, setBackground, setBackground, setClip, setRound, setSkin, stack, top |
Methods inherited from class com.badlogic.gdx.scenes.scene2d.ui.WidgetGroup |
---|
getMaxHeight, getMaxWidth, invalidateHierarchy, needsLayout, pack, setFillParent, setLayoutEnabled, validate |
Methods inherited from class com.badlogic.gdx.scenes.scene2d.Group |
---|
act, addActor, addActorAfter, addActorAt, addActorBefore, clear, findActor, getChildren, hasChildren, isTransform, localToDescendantCoordinates, print, setCullingArea, setTransform, swapActor, swapActor |
Methods inherited from class java.lang.Object |
---|
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Constructor Detail |
---|
public Button(Skin skin)
public Button(Skin skin, String styleName)
public Button(Actor child, Skin skin, String styleName)
public Button(Actor child, Button.ButtonStyle style)
public Button(Button.ButtonStyle style)
public Button()
public Button(Drawable up)
public Button(Drawable up, Drawable down)
public Button(Drawable up, Drawable down, Drawable checked)
public Button(Actor child, Skin skin)
Method Detail |
---|
public void setChecked(boolean isChecked)
public void toggle()
ChangeListener.ChangeEvent
, so can be used to
simulate a button click.
public boolean isChecked()
public boolean isPressed()
public boolean isOver()
public ClickListener getClickListener()
public boolean isDisabled()
public void setDisabled(boolean isDisabled)
isChecked()
when clicked and will not fire a ChangeListener.ChangeEvent
.
setDisabled
in interface Disableable
public void setStyle(Button.ButtonStyle style)
public Button.ButtonStyle getStyle()
setStyle(ButtonStyle)
is
called.
public void draw(Batch batch, float parentAlpha)
WidgetGroup
WidgetGroup.validate()
should be called to ensure the widget group is laid
out.
draw
in class Table
parentAlpha
- Should be multiplied with the actor's alpha, allowing a parent's alpha to affect all children.public float getPrefWidth()
getPrefWidth
in interface Layout
getPrefWidth
in class Table
public float getPrefHeight()
getPrefHeight
in interface Layout
getPrefHeight
in class Table
public float getMinWidth()
getMinWidth
in interface Layout
getMinWidth
in class Table
public float getMinHeight()
getMinHeight
in interface Layout
getMinHeight
in class Table
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |