public class SelectBox<T> extends Widget implements Disableable
ChangeListener.ChangeEvent is fired when the selectbox selection changes.
The preferred size of the select box is determined by the maximum text bounds of the items and the size of the
SelectBox.SelectBoxStyle.background.
| Modifier and Type | Class and Description |
|---|---|
static class |
SelectBox.SelectBoxStyle
The style for a select box, see
SelectBox. |
| Constructor and Description |
|---|
SelectBox(SelectBox.SelectBoxStyle style) |
SelectBox(Skin skin) |
SelectBox(Skin skin,
java.lang.String styleName) |
| Modifier and Type | Method and Description |
|---|---|
void |
clearItems() |
void |
draw(Batch batch,
float parentAlpha)
If this method is overridden, the super method or
Widget.validate() should be called to ensure the widget is laid out. |
protected GlyphLayout |
drawItem(Batch batch,
BitmapFont font,
T item,
float x,
float y,
float width) |
Array<T> |
getItems()
Returns the internal items array.
|
List<T> |
getList()
Returns the list shown when the select box is open.
|
int |
getMaxListCount() |
float |
getPrefHeight() |
float |
getPrefWidth() |
ScrollPane |
getScrollPane()
Returns the scroll pane containing the list that is shown when the select box is open.
|
T |
getSelected()
Returns the first selected item, or null.
|
int |
getSelectedIndex() |
ArraySelection<T> |
getSelection()
Get the set of selected items, useful when multiple items are selected
|
SelectBox.SelectBoxStyle |
getStyle()
Returns the select box's style.
|
void |
hideList() |
boolean |
isDisabled() |
void |
layout()
Computes and caches any information needed for drawing and, if this actor has children, positions and sizes each child,
calls
Layout.invalidate() on any each child whose width or height has changed, and calls Layout.validate() on each
child. |
protected void |
onHide(Actor selectBoxList) |
protected void |
onShow(Actor selectBoxList,
boolean below) |
void |
setAlignment(int alignment)
Sets the alignment of the selected item in the select box.
|
void |
setDisabled(boolean disabled) |
void |
setItems(Array<T> newItems)
Sets the items visible in the select box.
|
void |
setItems(T... newItems)
Set the backing Array that makes up the choices available in the SelectBox
|
void |
setMaxListCount(int maxListCount)
Set the max number of items to display when the select box is opened.
|
void |
setScrollingDisabled(boolean y)
Disables scrolling of the list shown when the select box is open.
|
void |
setSelected(T item)
Sets the selection to only the passed item, if it is a possible choice, else selects the first item.
|
void |
setSelectedIndex(int index)
Sets the selection to only the selected index.
|
protected void |
setStage(Stage stage)
Called by the framework when this actor or any parent is added to a group that is in the stage.
|
void |
setStyle(SelectBox.SelectBoxStyle style) |
void |
showList() |
protected java.lang.String |
toString(T obj) |
getMaxHeight, getMaxWidth, getMinHeight, getMinWidth, invalidate, invalidateHierarchy, needsLayout, pack, setFillParent, setLayoutEnabled, sizeChanged, validateact, addAction, addCaptureListener, addListener, clear, clearActions, clearListeners, clipBegin, clipBegin, clipEnd, debug, drawDebug, drawDebugBounds, fire, firstAscendant, 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, hit, isAscendantOf, isDescendantOf, isTouchable, isVisible, localToAscendantCoordinates, localToParentCoordinates, localToStageCoordinates, moveBy, notify, parentToLocalCoordinates, positionChanged, remove, removeAction, removeCaptureListener, removeListener, rotateBy, rotationChanged, scaleBy, scaleBy, screenToLocalCoordinates, setBounds, setColor, setColor, setDebug, setHeight, setName, setOrigin, setOrigin, setOriginX, setOriginY, setParent, setPosition, setPosition, setRotation, setScale, setScale, setScaleX, setScaleY, setSize, setTouchable, setUserObject, setVisible, setWidth, setX, setY, setZIndex, sizeBy, sizeBy, stageToLocalCoordinates, toBack, toFront, toStringpublic SelectBox(Skin skin)
public SelectBox(Skin skin, java.lang.String styleName)
public SelectBox(SelectBox.SelectBoxStyle style)
public void setMaxListCount(int maxListCount)
public int getMaxListCount()
protected void setStage(Stage stage)
Actorpublic void setStyle(SelectBox.SelectBoxStyle style)
public SelectBox.SelectBoxStyle getStyle()
setStyle(SelectBoxStyle)
is called.public void setItems(T... newItems)
public void clearItems()
public Array<T> getItems()
setItems(Array) must be called to reflect the changes.public void layout()
LayoutLayout.invalidate() on any each child whose width or height has changed, and calls Layout.validate() on each
child. This method should almost never be called directly, instead Layout.validate() should be used.public void draw(Batch batch, float parentAlpha)
WidgetWidget.validate() should be called to ensure the widget is laid out.protected GlyphLayout drawItem(Batch batch, BitmapFont font, T item, float x, float y, float width)
public void setAlignment(int alignment)
getList() and List.setAlignment(int) to set
the alignment in the list shown when the select box is open.alignment - See Align.public ArraySelection<T> getSelection()
public T getSelected()
getSelection().public void setSelected(T item)
public int getSelectedIndex()
public void setSelectedIndex(int index)
public void setDisabled(boolean disabled)
setDisabled in interface Disableablepublic boolean isDisabled()
isDisabled in interface Disableablepublic float getPrefWidth()
getPrefWidth in interface LayoutgetPrefWidth in class Widgetpublic float getPrefHeight()
getPrefHeight in interface LayoutgetPrefHeight in class Widgetprotected java.lang.String toString(T obj)
public void showList()
public void hideList()
public void setScrollingDisabled(boolean y)
public ScrollPane getScrollPane()
protected void onShow(Actor selectBoxList, boolean below)
protected void onHide(Actor selectBoxList)