Class KeyBinding

  • Direct Known Subclasses:
    KeyCharKeyBinding, KeyCodeKeyBinding

    public abstract class KeyBinding
    extends java.lang.Object
    Abstract base class for key bindings. A key binding consists of information about the bound key and an associated CommandList.
    • Constructor Summary

      Constructors 
      Modifier Constructor Description
      protected KeyBinding​(@NotNull CommandList commands, boolean isDefault)
      Creates a new instance.
    • Method Summary

      All Methods Instance Methods Abstract Methods Concrete Methods 
      Modifier and Type Method Description
      abstract boolean equals​(@Nullable java.lang.Object obj)  
      abstract @NotNull java.lang.String getBindingDescription()
      Return the binding as a human-readable text.
      @NotNull CommandList getCommands()
      Returns the associated CommandList.
      @NotNull java.lang.String getCommandString()
      Returns the commands as a string.
      abstract int hashCode()  
      boolean isDefault()
      Returns whether the key binding is a "default" binding which should not be saved.
      abstract boolean matchesKeyChar​(char keyChar)
      Check whether this key binding matches a key character.
      abstract boolean matchesKeyCode​(@NotNull KeyEvent2 keyEvent)
      Checks whether this key binding matches a key code/modifiers pair.
      • Methods inherited from class java.lang.Object

        clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • KeyBinding

        protected KeyBinding​(@NotNull
                             @NotNull CommandList commands,
                             boolean isDefault)
        Creates a new instance.
        Parameters:
        commands - the commands to execute
        isDefault - whether the key binding is a "default" binding which should not be saved
    • Method Detail

      • getCommands

        @NotNull
        public @NotNull CommandList getCommands()
        Returns the associated CommandList.
        Returns:
        the associated command list
      • equals

        public abstract boolean equals​(@Nullable
                                       @Nullable java.lang.Object obj)
        Overrides:
        equals in class java.lang.Object
      • hashCode

        public abstract int hashCode()
        Overrides:
        hashCode in class java.lang.Object
      • matchesKeyCode

        public abstract boolean matchesKeyCode​(@NotNull
                                               @NotNull KeyEvent2 keyEvent)
        Checks whether this key binding matches a key code/modifiers pair.
        Parameters:
        keyEvent - the key to check
        Returns:
        whether the key binding matches the parameters
      • matchesKeyChar

        public abstract boolean matchesKeyChar​(char keyChar)
        Check whether this key binding matches a key character.
        Parameters:
        keyChar - the key character to check
        Returns:
        whether the key binding matches the parameters
      • getBindingDescription

        @NotNull
        public abstract @NotNull java.lang.String getBindingDescription()
        Return the binding as a human-readable text.
        Returns:
        the human-readable text
      • getCommandString

        @NotNull
        public @NotNull java.lang.String getCommandString()
        Returns the commands as a string.
        Returns:
        the commands as a string
      • isDefault

        public boolean isDefault()
        Returns whether the key binding is a "default" binding which should not be saved.
        Returns:
        true=do not save