Component
, Interactable
, TextGUIElement
public class ActionListBox extends AbstractListBox<Runnable,ActionListBox>
AbstractListBox.DefaultListBoxRenderer<V,T extends AbstractListBox<V,T>>, AbstractListBox.ListItemRenderer<V,T extends AbstractListBox<V,T>>
Interactable.FocusChangeDirection, Interactable.Result
scrollOffset
Constructor | Description |
---|---|
ActionListBox() |
Default constructor, creates an
ActionListBox with no pre-defined size that will request to be big enough
to display all items |
ActionListBox(TerminalSize preferredSize) |
Creates a new
ActionListBox with a pre-set size. |
Modifier and Type | Method | Description |
---|---|---|
ActionListBox |
addItem(Runnable object) |
Adds one more item to the list box, at the end.
|
ActionListBox |
addItem(String label,
Runnable action) |
Adds a new item to the list, which is displayed in the list using a supplied label.
|
TerminalPosition |
getCursorLocation() |
Returns, in local coordinates, where to put the cursor on the screen when this component has focus.
|
Interactable.Result |
handleKeyStroke(KeyStroke keyStroke) |
This method can be overridden to handle various user input (mostly from the keyboard) when this component is in
focus.
|
void |
runSelectedItem() |
addTo, calculatePreferredSize, draw, getBasePane, getGlobalPosition, getLayoutData, getParent, getPosition, getPreferredSize, getSize, getTextGUI, getTheme, getThemeDefinition, hasParent, invalidate, isInside, isInvalid, isVisible, onAdded, onAfterDrawing, onBeforeDrawing, onRemoved, runOnGUIThreadIfExistsOtherwiseRunDirect, self, setLayoutData, setPosition, setPreferredSize, setRenderer, setSize, setTheme, setVisible, toBasePane, toGlobal, withBorder
afterLeaveFocus, getInputFilter, getRenderer, handleInput, isActivationStroke, isEnabled, isFocused, isKeyboardActivationStroke, isMouseActivationStroke, isMouseDown, isMouseDrag, isMouseMove, isMouseUp, onEnterFocus, onLeaveFocus, setEnabled, setInputFilter, takeFocus
afterEnterFocus, clearItems, createDefaultListItemRenderer, createDefaultRenderer, getIndexByMouseAction, getItemAt, getItemCount, getItems, getSelectedIndex, getSelectedItem, indexOf, isEmpty, isFocusable, removeItem, setListItemRenderer, setSelectedIndex
addTo, getBasePane, getGlobalPosition, getLayoutData, getParent, getPosition, getPreferredSize, getSize, getTextGUI, getTheme, getThemeDefinition, hasParent, invalidate, isInside, isVisible, onAdded, onRemoved, setLayoutData, setPosition, setPreferredSize, setSize, setTheme, setVisible, toBasePane, toGlobal, withBorder
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
draw, isInvalid
public ActionListBox()
ActionListBox
with no pre-defined size that will request to be big enough
to display all itemspublic ActionListBox(TerminalSize preferredSize)
ActionListBox
with a pre-set size. If the items don't fit in within this size, scrollbars
will be used to accommodate. Calling new ActionListBox(null)
has the same effect as calling
new ActionListBox()
.preferredSize
- Preferred size of this ActionListBox
public ActionListBox addItem(Runnable object)
.toString()
on the runnable, which
might not be what you want to have unless you explicitly declare it. Consider using
addItem(String label, Runnable action
instead, if you want to just set the label easily without having
to override .toString()
.addItem
in class AbstractListBox<Runnable,ActionListBox>
object
- Runnable to execute when the action was selected and fired in the listpublic ActionListBox addItem(String label, Runnable action)
label
- Label to use in the list for the new itemaction
- Runnable to invoke when this action is selected and then triggeredpublic TerminalPosition getCursorLocation()
Interactable
getCursorLocation
in interface Interactable
getCursorLocation
in class AbstractInteractableComponent<ActionListBox>
public Interactable.Result handleKeyStroke(KeyStroke keyStroke)
AbstractInteractableComponent
handleInput(..)
is final in
AbstractInteractableComponent
to ensure the input filter is properly handled. If the filter decides that
this event should be processed, it will call this method.handleKeyStroke
in class AbstractListBox<Runnable,ActionListBox>
keyStroke
- What input was entered by the userpublic void runSelectedItem()
Copyright © 2020. All rights reserved.