Skip to main content

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 — command is non-zero, subMenu is null. Selecting the item posts a cmXXXX command event. An optional keyCode hotkey and param label (e.g. "Ctrl+X") may be supplied.
  • Submenu item — command is zero, subMenu points to a nested JtvMenu. Selecting opens a child JtvMenuBox.
  • Separator — name is null. 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​

VisibilitySignature
publicJtvMenuItem(String name, int command)
publicJtvMenuItem(String name, int command, JtvKeyStroke keyStroke)
publicJtvMenuItem(String name, JtvKeyStroke keyStroke, JtvMenu subMenu)
publicJtvMenuItem(String name, int command, JtvKeyStroke keyStroke, int helpCtx, String param)
publicJtvMenuItem(String name, JtvKeyStroke keyStroke, JtvMenu subMenu, int helpCtx)

Fields​

ModifiersField nameType
privatenameString
privatecommandint
privatedisabledboolean
privatekeyStrokeorg.viktor44.jtvision.core.JtvKeyStroke
privatehelpCtxint
privateparamString
privatesubMenuorg.viktor44.jtvision.menus.JtvMenu

Methods​

ModifiersMethod signatureReturn type
publicgetName()String
publicsetName(String name)void
publicgetCommand()int
publicsetCommand(int command)void
publicisDisabled()boolean
publicsetDisabled(boolean disabled)void
publicgetKeyStroke()org.viktor44.jtvision.core.JtvKeyStroke
publicsetKeyStroke(JtvKeyStroke keyStroke)void
publicgetHelpCtx()int
publicsetHelpCtx(int helpCtx)void
publicgetParam()String
publicsetParam(String param)void
publicgetSubMenu()org.viktor44.jtvision.menus.JtvMenu
publicsetSubMenu(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 - the cmXXXX command 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 - the cmXXXX command to post on selection
  • keyStroke - the shortcut keystroke, or null

JtvMenuItem(String name, JtvKeyStroke keyStroke, JtvMenu subMenu)​

Creates a submenu item with no help context.

Parameters

  • name - the display label
  • keyStroke - the hot-key keystroke (Alt+letter), or null
  • subMenu - the nested JtvMenu to 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 label
  • command - the cmXXXX command to post on selection
  • keyStroke - the shortcut keystroke, or null
  • helpCtx - the help context number
  • param - the shortcut display string, or null

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 label
  • keyStroke - the hot-key keystroke (Alt+letter), or null
  • subMenu - the nested JtvMenu
  • helpCtx - 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