Record Class MenuRow

java.lang.Object
java.lang.Record
limn.backend.spi.MenuRow
Record Components:
id - the row's number in this reading; positive
kind - what the row is
label - the row's text, as the application wrote it: a backend escapes what its system reads as a marker; empty for a separator
enabled - whether it can be chosen; a submenu with no rows is not enabled
checked - for a MenuRow.Kind.CHECK, whether it is checked
mnemonic - the access letter, uppercased, or 0
children - a submenu's rows; empty for any other kind
icon - the picture before the label, or null
shortcutKey - the name of the accelerator's key with no modifier, as Q or F5; empty for no accelerator. A system shows it beside the label, and where the system runs a menu's keys while the menu is open, it chooses the row
shortcutModifiers - the accelerator's Keys modifier bits
edit - the editing command the row is, or null: such a row is enabled and chosen through the window that has the keyboard, by WindowInput.canEditFocused(limn.scene.EditCommand) and WindowInput.editFocused(limn.scene.EditCommand), and enabled says only whether the application disabled the item
mnemonicIndex - where in label the access letter is, as the text marked it, or -1 for the first occurrence of mnemonic

public record MenuRow(int id, MenuRow.Kind kind, String label, boolean enabled, boolean checked, char mnemonic, List<MenuRow> children, @Nullable Icon icon, String shortcutKey, int shortcutModifiers, @Nullable EditCommand edit, int mnemonicIndex) extends Record
One row of a menu the system draws (a tray's, a menu bar's) as a backend is handed it: what the three systems can draw of a menu's item, and a number to say back when the user chooses it.

The rows of one reading are numbered from 1 in the order they are read, a submenu's rows after their parent, so the same menu read twice has the same numbers. A number means nothing once the menu has been read again.

  • Constructor Details

    • MenuRow

      public MenuRow(int id, MenuRow.Kind kind, String label, boolean enabled, boolean checked, char mnemonic, List<MenuRow> children, @Nullable Icon icon, String shortcutKey, int shortcutModifiers)
      A row that is no editing command.
    • MenuRow

      public MenuRow(int id, MenuRow.Kind kind, String label, boolean enabled, boolean checked, char mnemonic, List<MenuRow> children)
      A row with no picture and no accelerator.
    • MenuRow

      public MenuRow(int id, MenuRow.Kind kind, String label, boolean enabled, boolean checked, char mnemonic, List<MenuRow> children, @Nullable Icon icon, String shortcutKey, int shortcutModifiers, @Nullable EditCommand edit, int mnemonicIndex)
      Creates an instance of a MenuRow record class.
      Parameters:
      id - the value for the id record component
      kind - the value for the kind record component
      label - the value for the label record component
      enabled - the value for the enabled record component
      checked - the value for the checked record component
      mnemonic - the value for the mnemonic record component
      children - the value for the children record component
      icon - the value for the icon record component
      shortcutKey - the value for the shortcutKey record component
      shortcutModifiers - the value for the shortcutModifiers record component
      edit - the value for the edit record component
      mnemonicIndex - the value for the mnemonicIndex record component
  • Method Details

    • withMnemonicIndex

      public MenuRow withMnemonicIndex(int index)
      This row with its access letter where the text marked it: index into the label.
    • mnemonicAt

      public int mnemonicAt()
      Where the access letter goes in the label: the marked place when the text marked one, else the first occurrence of the letter, else -1. The one answer each system's menu reads.
    • shortcutText

      public String shortcutText()
      Returns:
      the accelerator as the words a menu shows where it shows words, Ctrl+Shift+S, or "" for none
    • toString

      public final String toString()
      Returns a string representation of this record class. The representation contains the name of the class, followed by the name and value of each of the record components.
      Specified by:
      toString in class Record
      Returns:
      a string representation of this object
    • hashCode

      public final int hashCode()
      Returns a hash code value for this object. The value is derived from the hash code of each of the record components.
      Specified by:
      hashCode in class Record
      Returns:
      a hash code value for this object
    • equals

      public final boolean equals(Object o)
      Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. Reference components are compared with Objects::equals(Object,Object); primitive components are compared with '=='.
      Specified by:
      equals in class Record
      Parameters:
      o - the object with which to compare
      Returns:
      true if this object is the same as the o argument; false otherwise.
    • id

      public int id()
      Returns the value of the id record component.
      Returns:
      the value of the id record component
    • kind

      public MenuRow.Kind kind()
      Returns the value of the kind record component.
      Returns:
      the value of the kind record component
    • label

      public String label()
      Returns the value of the label record component.
      Returns:
      the value of the label record component
    • enabled

      public boolean enabled()
      Returns the value of the enabled record component.
      Returns:
      the value of the enabled record component
    • checked

      public boolean checked()
      Returns the value of the checked record component.
      Returns:
      the value of the checked record component
    • mnemonic

      public char mnemonic()
      Returns the value of the mnemonic record component.
      Returns:
      the value of the mnemonic record component
    • children

      public List<MenuRow> children()
      Returns the value of the children record component.
      Returns:
      the value of the children record component
    • icon

      public @Nullable Icon icon()
      Returns the value of the icon record component.
      Returns:
      the value of the icon record component
    • shortcutKey

      public String shortcutKey()
      Returns the value of the shortcutKey record component.
      Returns:
      the value of the shortcutKey record component
    • shortcutModifiers

      public int shortcutModifiers()
      Returns the value of the shortcutModifiers record component.
      Returns:
      the value of the shortcutModifiers record component
    • edit

      public @Nullable EditCommand edit()
      Returns the value of the edit record component.
      Returns:
      the value of the edit record component
    • mnemonicIndex

      public int mnemonicIndex()
      Returns the value of the mnemonicIndex record component.
      Returns:
      the value of the mnemonicIndex record component