public class Button extends Table implements Disableable
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.
Modifier and Type | Class and Description |
---|---|
static class |
Button.ButtonStyle
The style for a button, see
Button . |
Table.Debug, Table.DebugRect
backgroundBottom, backgroundLeft, backgroundRight, backgroundTop, debugActorColor, debugCellColor, debugTableColor
Constructor and Description |
---|
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) |
Modifier and Type | Method and Description |
---|---|
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. |
ButtonGroup |
getButtonGroup() |
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 |
setProgrammaticChangeEvents(boolean programmaticChangeEvents)
If false,
setChecked(boolean) and toggle() will not fire ChangeListener.ChangeEvent , event will be fired only when user clicked the checkbox |
void |
setStyle(Button.ButtonStyle style) |
void |
toggle()
Toggles the checked state.
|
add, add, add, add, add, add, add, align, background, background, bottom, center, clearChildren, columnDefaults, debug, debug, debugActor, debugAll, debugCell, debugTable, defaults, drawDebug, getAlign, getBackground, getCell, getCells, getClip, getColumns, getColumnWidth, getPadBottom, getPadBottomValue, getPadLeft, getPadLeftValue, getPadRight, getPadRightValue, getPadTop, getPadTopValue, getPadX, getPadY, getRow, getRowHeight, getRows, getSkin, getTableDebug, hit, invalidate, layout, left, pad, pad, pad, pad, padBottom, padBottom, padLeft, padLeft, padRight, padRight, padTop, padTop, removeActor, removeActor, reset, right, row, setBackground, setBackground, setClip, setDebug, setRound, setSkin, stack, top
getMaxHeight, getMaxWidth, invalidateHierarchy, needsLayout, pack, setFillParent, setLayoutEnabled, validate
act, addActor, addActorAfter, addActorAt, addActorBefore, clear, findActor, getChildren, getCullingArea, hasChildren, isTransform, localToDescendantCoordinates, setCullingArea, setDebug, setTransform, swapActor, swapActor, toString
addAction, addCaptureListener, addListener, clearActions, clearListeners, clipBegin, clipBegin, clipEnd, fire, getActions, getCaptureListeners, getColor, getDebug, getHeight, getListeners, getName, getOriginX, getOriginY, getParent, getRight, getRotation, getScaleX, getScaleY, getStage, getTop, getTouchable, getUserObject, getWidth, getX, getX, getY, getY, getZIndex, hasActions, hasParent, isAscendantOf, isDescendantOf, isTouchable, isVisible, localToAscendantCoordinates, localToParentCoordinates, localToStageCoordinates, moveBy, notify, parentToLocalCoordinates, remove, removeAction, removeCaptureListener, removeListener, rotateBy, scaleBy, scaleBy, screenToLocalCoordinates, setBounds, setColor, setColor, setHeight, setName, setOrigin, setOrigin, setOriginX, setOriginY, setPosition, setPosition, setRotation, setScale, setScale, setScaleX, setScaleY, setSize, setTouchable, setUserObject, setVisible, setWidth, setX, setY, setZIndex, sizeBy, sizeBy, stageToLocalCoordinates, toBack, toFront
public Button(Skin skin)
public Button(Actor child, Button.ButtonStyle style)
public Button(Button.ButtonStyle style)
public Button()
public Button(Drawable up)
public void setChecked(boolean isChecked)
public void toggle()
ChangeListener.ChangeEvent
(if programmatic change
events are enabled), so can be used to simulate a button click.public boolean isChecked()
public boolean isPressed()
public boolean isOver()
public ClickListener getClickListener()
public boolean isDisabled()
isDisabled
in interface Disableable
public void setDisabled(boolean isDisabled)
isChecked()
when clicked and will not fire a ChangeListener.ChangeEvent
.setDisabled
in interface Disableable
public void setProgrammaticChangeEvents(boolean programmaticChangeEvents)
setChecked(boolean)
and toggle()
will not fire ChangeListener.ChangeEvent
, event will be fired only when user clicked the checkboxpublic void setStyle(Button.ButtonStyle style)
public Button.ButtonStyle getStyle()
setStyle(ButtonStyle)
is
called.public ButtonGroup getButtonGroup()
public void draw(Batch batch, float parentAlpha)
WidgetGroup
WidgetGroup.validate()
should be called to ensure the widget group is laid
out.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
Copyright © 2015. All rights reserved.