Package jexer.menu
Class TMenuItem
- java.lang.Object
-
- jexer.TWidget
-
- jexer.menu.TMenuItem
-
- All Implemented Interfaces:
java.lang.Comparable<TWidget>
- Direct Known Subclasses:
TMenuSeparator,TSubMenu
public class TMenuItem extends TWidget
TMenuItem implements a menu item.
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voiddispatch(Backend backend)Dispatch event(s) due to selection or click.voiddraw()Draw a menu item with label.booleangetChecked()Get checkable flag.intgetIcon()Get a picture/emoji icon for this menu item.intgetId()Get the menu item ID.TKeypressgetKey()Get a global accelerator key for this menu item.MnemonicStringgetMnemonic()Get the mnemonic string for this menu item.voidonKeypress(TKeypressEvent keypress)Handle keystrokes.voidonMouseUp(TMouseEvent mouse)Handle mouse button releases.voidsetCheckable(boolean checkable)Set checkable flag.voidsetChecked(boolean checked)Set checked flag.voidsetIcon(int icon)Set a picture/emoji icon for this menu item.voidsetKey(TKeypress key)Set a global accelerator key for this menu item.-
Methods inherited from class jexer.TWidget
activate, activate, activate, activateAll, addButton, addCalendar, addCheckBox, addCheckBox, addComboBox, addDirectoryList, addDirectoryList, addDirectoryList, addDirectoryList, addEditor, addField, addField, addField, addField, addImage, addImage, addImage, addImage, addLabel, addLabel, addLabel, addLabel, addLabel, addLabel, addList, addList, addList, addList, addPanel, addPasswordField, addPasswordField, addPasswordField, addProgressBar, addRadioGroup, addRadioGroup, addSpinner, addSplitPane, addTable, addTable, addText, addText, addTreeViewWidget, addTreeViewWidget, close, compareTo, doRepaint, drawBox, drawBox, drawBoxShadow, drawChildren, fileOpenBox, fileOpenBox, fileOpenBox, fileOpenBox, fileSaveBox, getAbsoluteX, getAbsoluteY, getActiveChild, getApplication, getAttrXY, getChildren, getClipboard, getCursorAbsoluteX, getCursorAbsoluteY, getCursorX, getCursorY, getCustomMousePointer, getHeight, getLayoutManager, getLocale, getMouseStyle, getParent, getScreen, getTheme, getWidgetUnderMouse, getWidth, getWindow, getX, getY, handleEvent, hasChild, hLineXY, hLineXY, inputBox, inputBox, inputBox, isAbsoluteActive, isActive, isCursorVisible, isDrawable, isEchoKeystrokes, isEnabled, isPixelMouse, isVisible, messageBox, messageBox, mouseWouldHit, onCommand, onIdle, onMenu, onMouseDoubleClick, onMouseDown, onMouseMotion, onResize, putAll, putAttrXY, putAttrXY, putCharXY, putCharXY, putCharXY, putStringXY, putStringXY, remove, remove, remove, remove, removeAll, resetTabOrder, setActive, setCursorVisible, setCursorX, setCursorY, setCustomMousePointer, setDimensions, setEchoKeystrokes, setEchoKeystrokes, setEnabled, setHeight, setLayoutManager, setLocale, setMouseStyle, setParent, setupForTWindow, setVisible, setWidth, setWindow, setX, setY, splitHorizontal, splitVertical, switchWidget, toPrettyString, toPrettyString, toString, vLineXY, vLineXY
-
-
-
-
Method Detail
-
onMouseUp
public void onMouseUp(TMouseEvent mouse)
Handle mouse button releases.
-
onKeypress
public void onKeypress(TKeypressEvent keypress)
Handle keystrokes.- Overrides:
onKeypressin classTWidget- Parameters:
keypress- keystroke event
-
getId
public final int getId()
Get the menu item ID.- Returns:
- the id
-
setCheckable
public final void setCheckable(boolean checkable)
Set checkable flag.- Parameters:
checkable- if true, this menu item can be checked/unchecked
-
getChecked
public final boolean getChecked()
Get checkable flag.- Returns:
- true if this menu item is both checkable and checked
-
setChecked
public final void setChecked(boolean checked)
Set checked flag. Note that setting checked on an item checkable will do nothing.- Parameters:
checked- if true, and if this menu item is checkable, then getChecked() will return true
-
getMnemonic
public final MnemonicString getMnemonic()
Get the mnemonic string for this menu item.- Returns:
- mnemonic string
-
getKey
public final TKeypress getKey()
Get a global accelerator key for this menu item.- Returns:
- global keyboard accelerator, or null if no key is associated with this item
-
setKey
public final void setKey(TKeypress key)
Set a global accelerator key for this menu item.- Parameters:
key- global keyboard accelerator
-
getIcon
public final int getIcon()
Get a picture/emoji icon for this menu item.- Returns:
- the codepoint, or -1 if no icon is specified for this menu item
-
setIcon
public final void setIcon(int icon)
Set a picture/emoji icon for this menu item.- Parameters:
icon- a codepoint, or -1 to unset the icon
-
dispatch
public void dispatch(Backend backend)
Dispatch event(s) due to selection or click.- Parameters:
backend- the backend that generated the user input
-
-