Component, Interactable, TextGUIElementMenupublic class MenuItem extends AbstractInteractableComponent<MenuItem>
Menu with an optional action attached to it| Modifier and Type | Class | Description |
|---|---|---|
static class |
MenuItem.DefaultMenuItemRenderer |
Default renderer for menu items (both sub-menus and regular items)
|
static class |
MenuItem.MenuItemRenderer |
Helper interface that doesn't add any new methods but makes coding new menu renderers a little bit more clear
|
Interactable.FocusChangeDirection, Interactable.Result| Constructor | Description |
|---|---|
MenuItem(String label) |
Creates a
MenuItem with a label that does nothing when activated |
MenuItem(String label,
Runnable action) |
Creates a new
MenuItem with a label and an action that will run on the GUI thread when activated. |
| Modifier and Type | Method | Description |
|---|---|---|
protected InteractableRenderer<MenuItem> |
createDefaultRenderer() |
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).
|
String |
getLabel() |
Returns the label of this menu item
|
protected 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.
|
protected boolean |
onActivated() |
Method to invoke when a menu item is "activated" by pressing the Enter key.
|
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, withBorderafterEnterFocus, afterLeaveFocus, getCursorLocation, getInputFilter, getRenderer, handleInput, isActivationStroke, isEnabled, isFocusable, isFocused, isKeyboardActivationStroke, isMouseActivationStroke, isMouseDown, isMouseDrag, isMouseMove, isMouseUp, onEnterFocus, onLeaveFocus, setEnabled, setInputFilter, takeFocusaddTo, getBasePane, getGlobalPosition, getLayoutData, getParent, getPosition, getPreferredSize, getSize, getTextGUI, getTheme, getThemeDefinition, hasParent, invalidate, isInside, isVisible, onAdded, onRemoved, setLayoutData, setPosition, setPreferredSize, setSize, setTheme, setVisible, toBasePane, toGlobal, withBorderclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitdraw, isInvalidpublic MenuItem(String label)
MenuItem with a label that does nothing when activatedlabel - Label of the new MenuItempublic MenuItem(String label, Runnable action)
MenuItem with a label and an action that will run on the GUI thread when activated. When
the action has finished, the Menu containing this item will close.label - Label of the new MenuItemaction - Action to invoke on the GUI thread when the menu item is activatedpublic String getLabel()
protected InteractableRenderer<MenuItem> createDefaultRenderer()
AbstractComponentcreateDefaultRenderer in class AbstractInteractableComponent<MenuItem>protected boolean onActivated()
true if the action was performed successfully, otherwise false, which will not
automatically close the popup window itself.protected Interactable.Result handleKeyStroke(KeyStroke keyStroke)
AbstractInteractableComponenthandleInput(..) 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 AbstractInteractableComponent<MenuItem>keyStroke - What input was entered by the userCopyright © 2020. All rights reserved.