Class MenuItem
java.lang.Object
com.googlecode.lanterna.gui2.AbstractComponent<MenuItem>
com.googlecode.lanterna.gui2.AbstractInteractableComponent<MenuItem>
com.googlecode.lanterna.gui2.menu.MenuItem
- All Implemented Interfaces:
Component, Interactable, TextGUIElement
- Direct Known Subclasses:
Menu
This class is a single item that appears in a
Menu with an optional action attached to it-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classDefault renderer for menu items (both sub-menus and regular items)static classHelper interface that doesn't add any new methods but makes coding new menu renderers a little bit more clearNested classes/interfaces inherited from interface Interactable
Interactable.FocusChangeDirection, Interactable.Result -
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected InteractableRenderer<MenuItem> When you create a custom component, you need to implement this method and return a Renderer which is responsible for taking care of sizing the component, rendering it and choosing where to place the cursor (if Interactable).getLabel()Returns the label of this menu itemprotected Interactable.ResulthandleKeyStroke(KeyStroke keyStroke) This method can be overridden to handle various user input (mostly from the keyboard) when this component is in focus.protected booleanMethod to invoke when a menu item is "activated" by pressing the Enter key.Methods inherited from class AbstractInteractableComponent
afterEnterFocus, afterLeaveFocus, getCursorLocation, getInputFilter, getRenderer, handleInput, isActivationStroke, isEnabled, isFocusable, isFocused, isKeyboardActivationStroke, isMouseActivationStroke, isMouseDown, isMouseDrag, isMouseMove, isMouseUp, onEnterFocus, onLeaveFocus, setEnabled, setInputFilter, takeFocusMethods inherited from class AbstractComponent
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, withBorderMethods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface Component
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, withBorderMethods inherited from interface TextGUIElement
draw, isInvalid
-
Field Details
-
label
-
action
-
-
Constructor Details
-
MenuItem
-
MenuItem
-
-
Method Details
-
getLabel
-
createDefaultRenderer
Description copied from class:AbstractComponentWhen you create a custom component, you need to implement this method and return a Renderer which is responsible for taking care of sizing the component, rendering it and choosing where to place the cursor (if Interactable). This value is intended to be overridden by custom themes.- Specified by:
createDefaultRendererin classAbstractInteractableComponent<MenuItem>- Returns:
- Renderer to use when sizing and drawing this component
-
onActivated
protected boolean onActivated()Method to invoke when a menu item is "activated" by pressing the Enter key.- Returns:
- Returns
trueif the action was performed successfully, otherwisefalse, which will not automatically close the popup window itself.
-
handleKeyStroke
Description copied from class:AbstractInteractableComponentThis method can be overridden to handle various user input (mostly from the keyboard) when this component is in focus. The input method from the interface,handleInput(..)is final inAbstractInteractableComponentto ensure the input filter is properly handled. If the filter decides that this event should be processed, it will call this method.- Overrides:
handleKeyStrokein classAbstractInteractableComponent<MenuItem>- Parameters:
keyStroke- What input was entered by the user- Returns:
- Result of processing the key-stroke
-