public class Selection<T> extends Object implements Disableable, Iterable<T>
ChangeListener.ChangeEvent
on an actor. Selection changes can be vetoed via
Event.cancel()
.Constructor and Description |
---|
Selection() |
Modifier and Type | Method and Description |
---|---|
void |
add(T item)
Adds the item to the selection.
|
void |
addAll(Array<T> items) |
void |
choose(T item)
Selects or deselects the specified item based on how the selection is configured, whether ctrl is currently pressed, etc.
|
void |
clear() |
boolean |
contains(T item) |
boolean |
fireChangeEvent()
Fires a change event on the selection's actor, if any.
|
T |
first()
Returns the first selected item, or null.
|
T |
getLastSelected()
Makes a best effort to return the last item selected, else returns an arbitrary item or null if the selection is empty.
|
boolean |
getMultiple() |
boolean |
getRequired() |
boolean |
getToggle() |
boolean |
hasItems() |
boolean |
isDisabled() |
boolean |
isEmpty() |
OrderedSet<T> |
items() |
Iterator<T> |
iterator() |
void |
remove(T item) |
void |
removeAll(Array<T> items) |
void |
set(T item)
Sets the selection to only the specified item.
|
void |
setActor(Actor actor) |
void |
setAll(Array<T> items) |
void |
setDisabled(boolean isDisabled)
If true, prevents
choose(Object) from changing the selection. |
void |
setMultiple(boolean multiple)
If true, allows
choose(Object) to select multiple items. |
void |
setProgrammaticChangeEvents(boolean programmaticChangeEvents)
If false, only
choose(Object) will fire a change event. |
void |
setRequired(boolean required)
If true, prevents
choose(Object) from selecting none. |
void |
setToggle(boolean toggle)
If true, prevents
choose(Object) from clearing the selection. |
int |
size() |
Array<T> |
toArray() |
Array<T> |
toArray(Array<T> array) |
String |
toString() |
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
forEach, spliterator
public void setActor(Actor actor)
actor
- An actor to fire ChangeListener.ChangeEvent
on when the selection changes, or null.public void choose(T item)
public boolean hasItems()
public boolean isEmpty()
public int size()
public OrderedSet<T> items()
public T first()
public void set(T item)
public void add(T item)
public void remove(T item)
public void clear()
public boolean fireChangeEvent()
setProgrammaticChangeEvents(boolean)
.public boolean contains(T item)
public T getLastSelected()
public void setDisabled(boolean isDisabled)
choose(Object)
from changing the selection. Default is false.setDisabled
in interface Disableable
public boolean isDisabled()
isDisabled
in interface Disableable
public boolean getToggle()
public void setToggle(boolean toggle)
choose(Object)
from clearing the selection. Default is false.public boolean getMultiple()
public void setMultiple(boolean multiple)
choose(Object)
to select multiple items. Default is false.public boolean getRequired()
public void setRequired(boolean required)
choose(Object)
from selecting none. Default is false.public void setProgrammaticChangeEvents(boolean programmaticChangeEvents)
choose(Object)
will fire a change event. Default is true.Copyright © 2015. All rights reserved.