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 void
dispatch(Backend backend)
Dispatch event(s) due to selection or click.void
draw()
Draw a menu item with label.boolean
getChecked()
Get checkable flag.int
getIcon()
Get a picture/emoji icon for this menu item.int
getId()
Get the menu item ID.TKeypress
getKey()
Get a global accelerator key for this menu item.MnemonicString
getMnemonic()
Get the mnemonic string for this menu item.void
onKeypress(TKeypressEvent keypress)
Handle keystrokes.void
onMouseUp(TMouseEvent mouse)
Handle mouse button releases.void
setCheckable(boolean checkable)
Set checkable flag.void
setChecked(boolean checked)
Set checked flag.void
setIcon(int icon)
Set a picture/emoji icon for this menu item.void
setKey(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, 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, getHeight, getLayoutManager, getParent, getScreen, getTheme, getWidth, getWindow, getX, getY, handleEvent, hasChild, hLineXY, inputBox, inputBox, inputBox, isAbsoluteActive, isActive, isCursorVisible, isDrawable, isEchoKeystrokes, isEnabled, 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, setDimensions, setEchoKeystrokes, setEchoKeystrokes, setEnabled, setHeight, setLayoutManager, setParent, setupForTWindow, setVisible, setWidth, setWindow, setX, setY, splitHorizontal, splitVertical, switchWidget, toPrettyString, toPrettyString, toString, vLineXY
-
-
-
-
Method Detail
-
onMouseUp
public void onMouseUp(TMouseEvent mouse)
Handle mouse button releases.
-
onKeypress
public void onKeypress(TKeypressEvent keypress)
Handle keystrokes.- Overrides:
onKeypress
in 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
-
-