libgdx API

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

java.lang.Object
  extended by com.badlogic.gdx.scenes.scene2d.Actor
      extended by com.badlogic.gdx.scenes.scene2d.Group
          extended by com.badlogic.gdx.scenes.scene2d.ui.WidgetGroup
              extended by com.badlogic.gdx.scenes.scene2d.ui.tablelayout.Table
                  extended by com.badlogic.gdx.scenes.scene2d.ui.Button
All Implemented Interfaces:
Cullable, Layout
Direct Known Subclasses:
ImageButton, TextButton

public class Button
extends Table

A button is a Table with a checked state and additional style fields for pressed, unpressed, and checked. Being a table, a button can contain any other actors.

The preferred size of the button is determined by the background ninepatch and the button contents.

Author:
Nathan Sweet

Nested Class Summary
static class Button.ButtonStyle
          The style for a button, see Button.
 
Field Summary
 
Fields inherited from class com.badlogic.gdx.scenes.scene2d.ui.tablelayout.Table
clip, isPressed
 
Fields inherited from class com.badlogic.gdx.scenes.scene2d.Group
batchTransform, children, cullingArea, debug, debugTexture, groups, immutableChildren, immutableGroups, lastTouchedChild, localTransform, namesToActors, oldBatchTransform, point, transform, worldTransform
 
Fields inherited from class com.badlogic.gdx.scenes.scene2d.Actor
actions, color, height, name, originX, originY, parent, rotation, scaleX, scaleY, stage, touchable, visible, width, x, y
 
Constructor Summary
Button(Actor child, Button.ButtonStyle style)
           
Button(Actor child, Skin skin)
           
Button(Button.ButtonStyle style)
           
Button(Button.ButtonStyle style, java.lang.String name)
           
Button(NinePatch patch)
           
Button(NinePatch patchUp, NinePatch patchDown)
           
Button(NinePatch patchUp, NinePatch patchDown, NinePatch patchChecked)
           
Button(Skin skin)
           
Button(TextureRegion region)
           
Button(TextureRegion regionUp, TextureRegion regionDown)
           
Button(TextureRegion regionUp, TextureRegion regionDown, TextureRegion regionChecked)
           
 
Method Summary
 void draw(SpriteBatch 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.
 float getMinHeight()
           
 float getMinWidth()
           
 float getPrefHeight()
           
 float getPrefWidth()
           
 Button.ButtonStyle getStyle()
          Returns the button's style.
 boolean isChecked()
           
 void setChecked(boolean isChecked)
           
 void setClickListener(ClickListener listener)
           
 void setStyle(Button.ButtonStyle style)
           
 
Methods inherited from class com.badlogic.gdx.scenes.scene2d.ui.tablelayout.Table
add, add, add, align, align, bottom, center, clear, click, columnDefaults, debug, debug, debug, defaults, drawBackground, drawDebug, getAlign, getAllCells, getAllCells, getBackgroundPatch, getCell, getCell, getCells, getClickListener, getDebug, getHeight, getPadBottom, getPadLeft, getPadRight, getPadTop, getRow, getTableLayout, getWidget, getWidgets, getWidgets, height, height, invalidate, layout, left, newTable, pad, pad, pad, pad, padBottom, padBottom, padLeft, padLeft, padRight, padRight, padTop, padTop, parse, parse, register, reset, right, row, setAssetManager, setBackground, setClip, setSkin, setWidget, size, size, stack, top, touchDown, touchUp, width, width
 
Methods inherited from class com.badlogic.gdx.scenes.scene2d.ui.WidgetGroup
childrenChanged, getMaxHeight, getMaxWidth, invalidateHierarchy, needsLayout, pack, setFillParent, validate
 
Methods inherited from class com.badlogic.gdx.scenes.scene2d.Group
act, addActor, addActorAfter, addActorAt, addActorBefore, applyTransform, disableDebugging, drawChild, drawChildren, enableDebugging, findActor, getActors, getGroups, hit, isDescendant, removeActor, removeActorRecursive, resetTransform, setCullingArea, sortChildren, swapActor, swapActor, toChildCoordinates, toLocalCoordinates, touchMoved, updateTransform
 
Methods inherited from class com.badlogic.gdx.scenes.scene2d.Actor
action, clearActions, getStage, isMarkedToRemove, keyDown, keyTyped, keyUp, markToRemove, remove, scrolled, toLocalCoordinates, toString, touchDragged
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Button

public Button(Skin skin)

Button

public Button(Button.ButtonStyle style)

Button

public Button(Actor child,
              Button.ButtonStyle style)

Button

public Button(Button.ButtonStyle style,
              java.lang.String name)

Button

public Button(TextureRegion region)

Button

public Button(TextureRegion regionUp,
              TextureRegion regionDown)

Button

public Button(TextureRegion regionUp,
              TextureRegion regionDown,
              TextureRegion regionChecked)

Button

public Button(NinePatch patch)

Button

public Button(NinePatch patchUp,
              NinePatch patchDown)

Button

public Button(NinePatch patchUp,
              NinePatch patchDown,
              NinePatch patchChecked)

Button

public Button(Actor child,
              Skin skin)
Method Detail

setChecked

public void setChecked(boolean isChecked)

isChecked

public boolean isChecked()

setStyle

public void setStyle(Button.ButtonStyle style)

getStyle

public Button.ButtonStyle getStyle()
Returns the button's style. Modifying the returned style may not have an effect until setStyle(ButtonStyle) is called.


setClickListener

public void setClickListener(ClickListener listener)
Overrides:
setClickListener in class Table
Parameters:
listener - May be null.

draw

public void draw(SpriteBatch batch,
                 float parentAlpha)
Description copied from class: WidgetGroup
If this method is overridden, the super method or WidgetGroup.validate() should be called to ensure the widget group is laid out.

Overrides:
draw in class Table
Parameters:
batch - the spritebatch to render with
parentAlpha - the parent's alpha value.

getPrefWidth

public float getPrefWidth()
Specified by:
getPrefWidth in interface Layout
Overrides:
getPrefWidth in class Table

getPrefHeight

public float getPrefHeight()
Specified by:
getPrefHeight in interface Layout
Overrides:
getPrefHeight in class Table

getMinWidth

public float getMinWidth()
Specified by:
getMinWidth in interface Layout
Overrides:
getMinWidth in class Table

getMinHeight

public float getMinHeight()
Specified by:
getMinHeight in interface Layout
Overrides:
getMinHeight in class Table

libgdx API

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