Package jexer.menu
Class TMenu
- java.lang.Object
-
- jexer.TWidget
-
- jexer.TWindow
-
- jexer.menu.TMenu
-
-
Field Summary
-
Fields inherited from class jexer.TWindow
ABSOLUTEXY, CENTERED, helpTopic, HIDEONCLOSE, inKeyboardResize, inWindowMove, inWindowResize, MODAL, mouse, NOCLOSEBOX, NOZOOMBOX, OVERRIDEMENU, RESIZABLE, statusBar
-
-
Constructor Summary
Constructors Constructor Description TMenu(TApplication parent, int x, int y, java.lang.String label)
Public constructor.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description TMenuItem
addDefaultItem(int id)
Convenience function to add one of the default menu items.TMenuItem
addDefaultItem(int id, boolean enabled)
Convenience function to add one of the default menu items.TMenuItem
addItem(int id, java.lang.String label)
Convenience function to add a menu item.TMenuItem
addItem(int id, java.lang.String label, boolean enabled)
Convenience function to add a menu item.TMenuItem
addItem(int id, java.lang.String label, TKeypress key)
Convenience function to add a custom menu item.TMenuItem
addItem(int id, java.lang.String label, TKeypress key, boolean enabled)
Convenience function to add a custom menu item.void
addSeparator()
Convenience function to add a menu separator.TSubMenu
addSubMenu(java.lang.String title)
Convenience function to add a sub-menu.void
draw()
Draw a top-level menu with title and menu items.MnemonicString
getMnemonic()
Get the mnemonic string.int
getTitleX()
Get the menu title X position.boolean
isContext()
Get the context flag.void
onKeypress(TKeypressEvent keypress)
Handle keystrokes.void
onMouseDown(TMouseEvent mouse)
Handle mouse button presses.void
onMouseMotion(TMouseEvent mouse)
Handle mouse movements.void
onMouseUp(TMouseEvent mouse)
Handle mouse button releases.protected void
resetTabOrder()
Reset the tab order of children to match their position in the list.void
setContext(boolean context)
Set the context flag.void
setContext(boolean context, int x, int y)
Set the context flag, used to open a context menu at a specific screen position.void
setTitleX(int titleX)
Set the menu title X position.-
Methods inherited from class jexer.TWindow
activate, addShortcutKeypress, center, clearShortcutKeypresses, close, ensureOnScreen, getApplication, getBackground, getBorder, getBorderControls, getHelpTopic, getMaximumWindowHeight, getMaximumWindowWidth, getMinimumWindowHeight, getMinimumWindowWidth, getScreen, getStatusBar, getTitle, getZ, hasCloseBox, hasHiddenMouse, hasOverriddenMenu, hasZoomBox, hide, inMovements, isHidden, isModal, isResizable, isShortcutKeypress, isShown, maximize, mouseOnClose, mouseOnMaximize, mouseOnResize, newStatusBar, onClose, onCommand, onFocus, onHide, onMenu, onPreClose, onResize, onShow, onUnfocus, removeShortcutKeypress, restore, setCloseBox, setHiddenMouse, setMaximumWindowHeight, setMaximumWindowWidth, setMinimumWindowHeight, setMinimumWindowWidth, setResizable, setTitle, setZ, setZoomBox, show, stopMovements, toString
-
Methods inherited from class jexer.TWidget
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, compareTo, doRepaint, drawBox, drawBox, drawBoxShadow, drawChildren, fileOpenBox, fileOpenBox, fileOpenBox, fileOpenBox, fileSaveBox, getAbsoluteX, getAbsoluteY, getActiveChild, getAttrXY, getChildren, getClipboard, getCursorAbsoluteX, getCursorAbsoluteY, getCursorX, getCursorY, getHeight, getLayoutManager, getParent, getTheme, getWidth, getWindow, getX, getY, handleEvent, hasChild, hLineXY, inputBox, inputBox, inputBox, isAbsoluteActive, isActive, isCursorVisible, isDrawable, isEchoKeystrokes, isEnabled, isVisible, messageBox, messageBox, mouseWouldHit, onIdle, onMouseDoubleClick, putAll, putAttrXY, putAttrXY, putCharXY, putCharXY, putCharXY, putStringXY, putStringXY, remove, remove, remove, remove, removeAll, setActive, setCursorVisible, setCursorX, setCursorY, setDimensions, setEchoKeystrokes, setEchoKeystrokes, setEnabled, setHeight, setLayoutManager, setParent, setupForTWindow, setVisible, setWidth, setWindow, setX, setY, splitHorizontal, splitVertical, switchWidget, toPrettyString, toPrettyString, vLineXY
-
-
-
-
Field Detail
-
MID_UNUSED
public static final int MID_UNUSED
- See Also:
- Constant Field Values
-
MID_REPAINT
public static final int MID_REPAINT
- See Also:
- Constant Field Values
-
MID_VIEW_IMAGE
public static final int MID_VIEW_IMAGE
- See Also:
- Constant Field Values
-
MID_SCREEN_OPTIONS
public static final int MID_SCREEN_OPTIONS
- See Also:
- Constant Field Values
-
MID_NEW
public static final int MID_NEW
- See Also:
- Constant Field Values
-
MID_EXIT
public static final int MID_EXIT
- See Also:
- Constant Field Values
-
MID_QUIT
public static final int MID_QUIT
- See Also:
- Constant Field Values
-
MID_OPEN_FILE
public static final int MID_OPEN_FILE
- See Also:
- Constant Field Values
-
MID_SHELL
public static final int MID_SHELL
- See Also:
- Constant Field Values
-
MID_UNDO
public static final int MID_UNDO
- See Also:
- Constant Field Values
-
MID_REDO
public static final int MID_REDO
- See Also:
- Constant Field Values
-
MID_CUT
public static final int MID_CUT
- See Also:
- Constant Field Values
-
MID_COPY
public static final int MID_COPY
- See Also:
- Constant Field Values
-
MID_PASTE
public static final int MID_PASTE
- See Also:
- Constant Field Values
-
MID_CLEAR
public static final int MID_CLEAR
- See Also:
- Constant Field Values
-
MID_FIND
public static final int MID_FIND
- See Also:
- Constant Field Values
-
MID_REPLACE
public static final int MID_REPLACE
- See Also:
- Constant Field Values
-
MID_SEARCH_AGAIN
public static final int MID_SEARCH_AGAIN
- See Also:
- Constant Field Values
-
MID_GOTO_LINE
public static final int MID_GOTO_LINE
- See Also:
- Constant Field Values
-
MID_TILE
public static final int MID_TILE
- See Also:
- Constant Field Values
-
MID_CASCADE
public static final int MID_CASCADE
- See Also:
- Constant Field Values
-
MID_CLOSE_ALL
public static final int MID_CLOSE_ALL
- See Also:
- Constant Field Values
-
MID_WINDOW_MOVE
public static final int MID_WINDOW_MOVE
- See Also:
- Constant Field Values
-
MID_WINDOW_ZOOM
public static final int MID_WINDOW_ZOOM
- See Also:
- Constant Field Values
-
MID_WINDOW_NEXT
public static final int MID_WINDOW_NEXT
- See Also:
- Constant Field Values
-
MID_WINDOW_PREVIOUS
public static final int MID_WINDOW_PREVIOUS
- See Also:
- Constant Field Values
-
MID_WINDOW_CLOSE
public static final int MID_WINDOW_CLOSE
- See Also:
- Constant Field Values
-
MID_HELP_CONTENTS
public static final int MID_HELP_CONTENTS
- See Also:
- Constant Field Values
-
MID_HELP_INDEX
public static final int MID_HELP_INDEX
- See Also:
- Constant Field Values
-
MID_HELP_SEARCH
public static final int MID_HELP_SEARCH
- See Also:
- Constant Field Values
-
MID_HELP_PREVIOUS
public static final int MID_HELP_PREVIOUS
- See Also:
- Constant Field Values
-
MID_HELP_HELP
public static final int MID_HELP_HELP
- See Also:
- Constant Field Values
-
MID_HELP_ACTIVE_FILE
public static final int MID_HELP_ACTIVE_FILE
- See Also:
- Constant Field Values
-
MID_ABOUT
public static final int MID_ABOUT
- See Also:
- Constant Field Values
-
MID_TABLE_RENAME_ROW
public static final int MID_TABLE_RENAME_ROW
- See Also:
- Constant Field Values
-
MID_TABLE_RENAME_COLUMN
public static final int MID_TABLE_RENAME_COLUMN
- See Also:
- Constant Field Values
-
MID_TABLE_VIEW_ROW_LABELS
public static final int MID_TABLE_VIEW_ROW_LABELS
- See Also:
- Constant Field Values
-
MID_TABLE_VIEW_COLUMN_LABELS
public static final int MID_TABLE_VIEW_COLUMN_LABELS
- See Also:
- Constant Field Values
-
MID_TABLE_VIEW_HIGHLIGHT_ROW
public static final int MID_TABLE_VIEW_HIGHLIGHT_ROW
- See Also:
- Constant Field Values
-
MID_TABLE_VIEW_HIGHLIGHT_COLUMN
public static final int MID_TABLE_VIEW_HIGHLIGHT_COLUMN
- See Also:
- Constant Field Values
-
MID_TABLE_BORDER_NONE
public static final int MID_TABLE_BORDER_NONE
- See Also:
- Constant Field Values
-
MID_TABLE_BORDER_ALL
public static final int MID_TABLE_BORDER_ALL
- See Also:
- Constant Field Values
-
MID_TABLE_BORDER_CELL_NONE
public static final int MID_TABLE_BORDER_CELL_NONE
- See Also:
- Constant Field Values
-
MID_TABLE_BORDER_CELL_ALL
public static final int MID_TABLE_BORDER_CELL_ALL
- See Also:
- Constant Field Values
-
MID_TABLE_BORDER_RIGHT
public static final int MID_TABLE_BORDER_RIGHT
- See Also:
- Constant Field Values
-
MID_TABLE_BORDER_LEFT
public static final int MID_TABLE_BORDER_LEFT
- See Also:
- Constant Field Values
-
MID_TABLE_BORDER_TOP
public static final int MID_TABLE_BORDER_TOP
- See Also:
- Constant Field Values
-
MID_TABLE_BORDER_BOTTOM
public static final int MID_TABLE_BORDER_BOTTOM
- See Also:
- Constant Field Values
-
MID_TABLE_BORDER_DOUBLE_BOTTOM
public static final int MID_TABLE_BORDER_DOUBLE_BOTTOM
- See Also:
- Constant Field Values
-
MID_TABLE_BORDER_THICK_BOTTOM
public static final int MID_TABLE_BORDER_THICK_BOTTOM
- See Also:
- Constant Field Values
-
MID_TABLE_DELETE_LEFT
public static final int MID_TABLE_DELETE_LEFT
- See Also:
- Constant Field Values
-
MID_TABLE_DELETE_UP
public static final int MID_TABLE_DELETE_UP
- See Also:
- Constant Field Values
-
MID_TABLE_DELETE_ROW
public static final int MID_TABLE_DELETE_ROW
- See Also:
- Constant Field Values
-
MID_TABLE_DELETE_COLUMN
public static final int MID_TABLE_DELETE_COLUMN
- See Also:
- Constant Field Values
-
MID_TABLE_INSERT_LEFT
public static final int MID_TABLE_INSERT_LEFT
- See Also:
- Constant Field Values
-
MID_TABLE_INSERT_RIGHT
public static final int MID_TABLE_INSERT_RIGHT
- See Also:
- Constant Field Values
-
MID_TABLE_INSERT_ABOVE
public static final int MID_TABLE_INSERT_ABOVE
- See Also:
- Constant Field Values
-
MID_TABLE_INSERT_BELOW
public static final int MID_TABLE_INSERT_BELOW
- See Also:
- Constant Field Values
-
MID_TABLE_COLUMN_NARROW
public static final int MID_TABLE_COLUMN_NARROW
- See Also:
- Constant Field Values
-
MID_TABLE_COLUMN_WIDEN
public static final int MID_TABLE_COLUMN_WIDEN
- See Also:
- Constant Field Values
-
MID_TABLE_FILE_OPEN_CSV
public static final int MID_TABLE_FILE_OPEN_CSV
- See Also:
- Constant Field Values
-
MID_TABLE_FILE_SAVE_CSV
public static final int MID_TABLE_FILE_SAVE_CSV
- See Also:
- Constant Field Values
-
MID_TABLE_FILE_SAVE_TEXT
public static final int MID_TABLE_FILE_SAVE_TEXT
- See Also:
- Constant Field Values
-
-
Constructor Detail
-
TMenu
public TMenu(TApplication parent, int x, int y, java.lang.String label)
Public constructor.- Parameters:
parent
- parent applicationx
- column relative to parenty
- row relative to parentlabel
- mnemonic menu title. Label must contain a keyboard shortcut (mnemonic), denoted by prefixing a letter with "&", e.g. "&File"
-
-
Method Detail
-
onMouseDown
public void onMouseDown(TMouseEvent mouse)
Handle mouse button presses.- Overrides:
onMouseDown
in classTWindow
- Parameters:
mouse
- mouse button event
-
onMouseUp
public void onMouseUp(TMouseEvent mouse)
Handle mouse button releases.
-
onMouseMotion
public void onMouseMotion(TMouseEvent mouse)
Handle mouse movements.- Overrides:
onMouseMotion
in classTWindow
- Parameters:
mouse
- mouse motion event
-
onKeypress
public void onKeypress(TKeypressEvent keypress)
Handle keystrokes.- Overrides:
onKeypress
in classTWindow
- Parameters:
keypress
- keystroke event
-
draw
public void draw()
Draw a top-level menu with title and menu items.
-
setTitleX
public void setTitleX(int titleX)
Set the menu title X position.- Parameters:
titleX
- the position
-
getTitleX
public int getTitleX()
Get the menu title X position.- Returns:
- the position
-
getMnemonic
public MnemonicString getMnemonic()
Get the mnemonic string.- Returns:
- the full mnemonic string
-
isContext
public boolean isContext()
Get the context flag.- Returns:
- true if this menu is a right-click context menu
-
setContext
public void setContext(boolean context, int x, int y)
Set the context flag, used to open a context menu at a specific screen position.- Parameters:
context
- if true, this is a context menux
- the screen X positiony
- the screen Y position
-
setContext
public void setContext(boolean context)
Set the context flag.- Parameters:
context
- if true, this is a context menu
-
addItem
public TMenuItem addItem(int id, java.lang.String label)
Convenience function to add a menu item.- Parameters:
id
- menu item ID. Must be greater than 1024.label
- menu item label- Returns:
- the new menu item
-
addItem
public TMenuItem addItem(int id, java.lang.String label, boolean enabled)
Convenience function to add a menu item.- Parameters:
id
- menu item ID. Must be greater than 1024.label
- menu item labelenabled
- default state for enabled- Returns:
- the new menu item
-
addItem
public TMenuItem addItem(int id, java.lang.String label, TKeypress key)
Convenience function to add a custom menu item.- Parameters:
id
- menu item ID. Must be greater than 1024.label
- menu item labelkey
- global keyboard accelerator- Returns:
- the new menu item
-
addItem
public TMenuItem addItem(int id, java.lang.String label, TKeypress key, boolean enabled)
Convenience function to add a custom menu item.- Parameters:
id
- menu item ID. Must be greater than 1024.label
- menu item labelkey
- global keyboard acceleratorenabled
- default state for enabled- Returns:
- the new menu item
-
addDefaultItem
public TMenuItem addDefaultItem(int id)
Convenience function to add one of the default menu items.- Parameters:
id
- menu item ID. Must be between 0 (inclusive) and 1023 (inclusive).- Returns:
- the new menu item
-
addDefaultItem
public TMenuItem addDefaultItem(int id, boolean enabled)
Convenience function to add one of the default menu items.- Parameters:
id
- menu item ID. Must be between 0 (inclusive) and 1023 (inclusive).enabled
- default state for enabled- Returns:
- the new menu item
-
addSeparator
public void addSeparator()
Convenience function to add a menu separator.
-
addSubMenu
public TSubMenu addSubMenu(java.lang.String title)
Convenience function to add a sub-menu.- Parameters:
title
- menu title. Title must contain a keyboard shortcut, denoted by prefixing a letter with "&", e.g. "&File"- Returns:
- the new sub-menu
-
resetTabOrder
protected void resetTabOrder()
Reset the tab order of children to match their position in the list. Available so that subclasses can re-order their widgets if needed.- Overrides:
resetTabOrder
in classTWidget
-
-