Class JtvMenuItem
public class JtvMenuItem
A single menu item record.
JtvMenuItem represents one entry in a JtvMenu: a selectable action, a submenu trigger, or a visual separator (divider line).
Item kinds
- Command item —
commandis non-zero,subMenuisnull. Selecting the item posts acmXXXXcommand event. An optionalkeyCodehotkey andparamlabel (e.g."Ctrl+X") may be supplied. - Submenu item —
commandis zero,subMenupoints to a nested JtvMenu. Selecting opens a child JtvMenuBox. - Separator —
nameisnull. Rendered as a horizontal divider line inside a JtvMenuBox.
Hot keys
keyCode holds the scan code of a keyboard shortcut that triggers
the item directly (typically a function key or Alt+letter combination).
JtvMenuView scans the key code during evKeyDown events.
Enabled state
disabled is initialised from the current command set via
JtvView.commandEnabled(int), and is updated whenever a
cmCommandSetChanged broadcast is received.
org.viktor44.jtvision.menus.JtvMenuItem
Summary
Constructors
Fields
| Modifiers | Field name | Type |
|---|---|---|
| private | name | String |
| private | command | int |
| private | disabled | boolean |
| private | keyStroke | org.viktor44.jtvision.core.JtvKeyStroke |
| private | helpCtx | int |
| private | param | String |
| private | subMenu | org.viktor44.jtvision.menus.JtvMenu |
Methods
| Modifiers | Method signature | Return type |
|---|---|---|
| public | getName() | String |
| public | setName(String name) | void |
| public | getCommand() | int |
| public | setCommand(int command) | void |
| public | isDisabled() | boolean |
| public | setDisabled(boolean disabled) | void |
| public | getKeyStroke() | org.viktor44.jtvision.core.JtvKeyStroke |
| public | setKeyStroke(JtvKeyStroke keyStroke) | void |
| public | getHelpCtx() | int |
| public | setHelpCtx(int helpCtx) | void |
| public | getParam() | String |
| public | setParam(String param) | void |
| public | getSubMenu() | org.viktor44.jtvision.menus.JtvMenu |
| public | setSubMenu(JtvMenu subMenu) | void |
Constructors
JtvMenuItem(String name, int command)
Creates a command menu item.
Parameters
name- the display label (may contain~hot-key markers)command- thecmXXXXcommand to post on selection
JtvMenuItem(String name, int command, JtvKeyStroke keyStroke)
Creates a command menu item with no help context and no param string.
Parameters
name- the display label (may contain~hot-key markers)command- thecmXXXXcommand to post on selectionkeyStroke- the shortcut keystroke, ornull
JtvMenuItem(String name, JtvKeyStroke keyStroke, JtvMenu subMenu)
Creates a submenu item with no help context.
Parameters
name- the display labelkeyStroke- the hot-key keystroke (Alt+letter), ornullsubMenu- the nestedJtvMenuto open on selection
JtvMenuItem(String name, int command, JtvKeyStroke keyStroke, int helpCtx, String param)
Creates a command menu item with all fields specified.
disabled is set from the current command set.
Parameters
name- the display labelcommand- thecmXXXXcommand to post on selectionkeyStroke- the shortcut keystroke, ornullhelpCtx- the help context numberparam- the shortcut display string, ornull
JtvMenuItem(String name, JtvKeyStroke keyStroke, JtvMenu subMenu, int helpCtx)
Creates a submenu item. command is set to 0 and
disabled is always false — submenu items are never
disabled through the command set.
Parameters
name- the display labelkeyStroke- the hot-key keystroke (Alt+letter), ornullsubMenu- the nestedJtvMenuhelpCtx- the help context number
Fields
String name
The display label for this menu item, with an optional tilde
(~) surrounding the hot-key letter, e.g. "~F~ile".
null for separator lines.
int command
The cmXXXX command constant posted when the item is selected,
or 0 for submenu items.
boolean disabled
true if this item is currently disabled and cannot be selected.
Reflects JtvView.commandEnabled(int) at construction time and is
refreshed on cmCommandSetChanged broadcasts.
org.viktor44.jtvision.core.JtvKeyStroke keyStroke
The keystroke shortcut that triggers this item directly, or null
if there is no shortcut.
int helpCtx
The help context number for this item. org.viktor44.jtvision.core.ViewFlags.hcNoContext indicates no context is assigned.
String param
The keyboard shortcut display string shown to the right of the item
inside a JtvMenuBox, e.g. "Ctrl+X". null for
submenu items or items with no displayable shortcut.
org.viktor44.jtvision.menus.JtvMenu subMenu
For submenu items (command == 0), points to the nested
JtvMenu that is opened when the item is selected. null
for command items and separators.
Methods
getName()
The display label for this menu item, with an optional tilde
(~) surrounding the hot-key letter, e.g. "~F~ile".
null for separator lines.
setName(String name)
The display label for this menu item, with an optional tilde
(~) surrounding the hot-key letter, e.g. "~F~ile".
null for separator lines.
Parameters
name
getCommand()
The cmXXXX command constant posted when the item is selected,
or 0 for submenu items.
setCommand(int command)
The cmXXXX command constant posted when the item is selected,
or 0 for submenu items.
Parameters
command
isDisabled()
true if this item is currently disabled and cannot be selected.
Reflects JtvView.commandEnabled(int) at construction time and is
refreshed on cmCommandSetChanged broadcasts.
setDisabled(boolean disabled)
true if this item is currently disabled and cannot be selected.
Reflects JtvView.commandEnabled(int) at construction time and is
refreshed on cmCommandSetChanged broadcasts.
Parameters
disabled
getKeyStroke()
The keystroke shortcut that triggers this item directly, or null
if there is no shortcut.
setKeyStroke(JtvKeyStroke keyStroke)
The keystroke shortcut that triggers this item directly, or null
if there is no shortcut.
Parameters
keyStroke
getHelpCtx()
The help context number for this item. org.viktor44.jtvision.core.ViewFlags.hcNoContext indicates no context is assigned.
setHelpCtx(int helpCtx)
The help context number for this item. org.viktor44.jtvision.core.ViewFlags.hcNoContext indicates no context is assigned.
Parameters
helpCtx
getParam()
The keyboard shortcut display string shown to the right of the item
inside a JtvMenuBox, e.g. "Ctrl+X". null for
submenu items or items with no displayable shortcut.
setParam(String param)
The keyboard shortcut display string shown to the right of the item
inside a JtvMenuBox, e.g. "Ctrl+X". null for
submenu items or items with no displayable shortcut.
Parameters
param
getSubMenu()
For submenu items (command == 0), points to the nested
JtvMenu that is opened when the item is selected. null
for command items and separators.
setSubMenu(JtvMenu subMenu)
For submenu items (command == 0), points to the nested
JtvMenu that is opened when the item is selected. null
for command items and separators.
Parameters
subMenu