Record Class KeystrokeTriggerConfig

java.lang.Object
java.lang.Record
com.inductiveautomation.factorypmi.designer.workspace.KeystrokeTriggerConfig
Record Components:
modifiers - the modifiers that must be held; empty for none.
action - when the script fires.
key - the key name for KeystrokeChooser.Action.PRESSED and KeystrokeChooser.Action.RELEASED, else null.
character - the single character for KeystrokeChooser.Action.TYPED, else null.

@NullMarked public record KeystrokeTriggerConfig(Set<KeystrokeChooser.Modifier> modifiers, KeystrokeChooser.Action action, @Nullable String key, @Nullable String character) extends Record
The trigger configuration of a Vision client keystroke event script: the keystroke that fires it, as the keystroke chooser edits it.

Which of key and character applies depends on action, a cross-member rule the JSON schema cannot express, so this type uses a hand-written extractor that also rejects a key the chooser's Key list does not offer — a binding the chooser could not display.

  • Field Details

  • Constructor Details

  • Method Details

    • binding

      public @Nullable String binding()
      The member action uses: the slot after the action word in the stroke string.
      Returns:
      the key name for KeystrokeChooser.Action.PRESSED and KeystrokeChooser.Action.RELEASED, or the character for KeystrokeChooser.Action.TYPED — the slot after the action word in the stroke string; null if unset.
    • fromStroke

      public static KeystrokeTriggerConfig fromStroke(String stroke)
      Reads a stroke string in the form the chooser saves — for example "ctrl pressed S" or "typed !". Lenient, because it describes the chooser's live state, which may be mid-edit: a "Typed" stroke comes back with the character box text exactly as typed, spaces and keyword-like words included, or a null character when the box is empty, rather than failing.
      Parameters:
      stroke - a stroke string from KeystrokeChooser.getStroke().
      Returns:
      the configuration the stroke describes.
    • toStroke

      public String toStroke()
      Returns:
      this configuration as a stroke string the chooser can load, for example "ctrl pressed S".
    • 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. All components in this record class are compared with Objects::equals(Object,Object).
      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.
    • modifiers

      public Set<KeystrokeChooser.Modifier> modifiers()
      Returns the value of the modifiers record component.
      Returns:
      the value of the modifiers record component
    • action

      public KeystrokeChooser.Action action()
      Returns the value of the action record component.
      Returns:
      the value of the action record component
    • key

      public @Nullable String key()
      Returns the value of the key record component.
      Returns:
      the value of the key record component
    • character

      public @Nullable String character()
      Returns the value of the character record component.
      Returns:
      the value of the character record component