Class MouseEvent

java.lang.Object
org.aesh.terminal.tty.MouseEvent

public final class MouseEvent extends Object
Represents a mouse event from the terminal.

Mouse events are produced when mouse tracking is enabled via MouseTracking and the terminal sends mouse reports. The event includes the type (press, release, drag, move, scroll), the button involved, the position (1-based), and modifier keys.

See Also:
  • Nested Class Summary

    Nested Classes
    Modifier and Type
    Class
    Description
    static enum 
    The mouse button involved in the event.
    static enum 
    The type of mouse event.
  • Constructor Summary

    Constructors
    Constructor
    Description
    MouseEvent(MouseEvent.Type type, MouseEvent.Button button, int x, int y, boolean shift, boolean alt, boolean ctrl)
    Creates a new mouse event.
  • Method Summary

    Modifier and Type
    Method
    Description
    boolean
    alt()
    Returns true if alt/meta was held.
    Returns the button.
    boolean
    Returns true if ctrl was held.
    boolean
     
    int
     
    static boolean
    isSgrMouseEvent(int finalChar, int[] intermediates, int intermediateCount)
    Checks if a CSI dispatch represents an SGR mouse event.
    static MouseEvent
    parseSgr(int finalChar, int[] params, int paramCount)
    Parses an SGR mouse event from a CSI dispatch.
    boolean
    Returns true if shift was held.
     
    Returns the event type.
    int
    x()
    Returns the column (1-based).
    int
    y()
    Returns the row (1-based).

    Methods inherited from class Object

    clone, finalize, getClass, notify, notifyAll, wait, wait, wait
  • Constructor Details

    • MouseEvent

      public MouseEvent(MouseEvent.Type type, MouseEvent.Button button, int x, int y, boolean shift, boolean alt, boolean ctrl)
      Creates a new mouse event.
      Parameters:
      type - the event type
      button - the button
      x - the column (1-based)
      y - the row (1-based)
      shift - true if shift was held
      alt - true if alt/meta was held
      ctrl - true if ctrl was held
  • Method Details

    • type

      public MouseEvent.Type type()
      Returns the event type.
      Returns:
      the event type
    • button

      public MouseEvent.Button button()
      Returns the button.
      Returns:
      the button
    • x

      public int x()
      Returns the column (1-based).
      Returns:
      the column position
    • y

      public int y()
      Returns the row (1-based).
      Returns:
      the row position
    • shift

      public boolean shift()
      Returns true if shift was held.
      Returns:
      true if shift was held
    • alt

      public boolean alt()
      Returns true if alt/meta was held.
      Returns:
      true if alt/meta was held
    • ctrl

      public boolean ctrl()
      Returns true if ctrl was held.
      Returns:
      true if ctrl was held
    • parseSgr

      public static MouseEvent parseSgr(int finalChar, int[] params, int paramCount)
      Parses an SGR mouse event from a CSI dispatch.

      SGR format: CSI < Pb ; Px ; Py M (press/drag/move/scroll) or CSI < Pb ; Px ; Py m (release).

      This method is designed to be called directly from a VtHandler.csiDispatch(int, int[], int, int[], int, boolean) callback when the private marker is <.

      Parameters:
      finalChar - the final character ('M' for press, 'm' for release)
      params - the CSI parameters [Pb, Px, Py]
      paramCount - the number of parameters (must be 3)
      Returns:
      the parsed mouse event, or null if the parameters are invalid
    • isSgrMouseEvent

      public static boolean isSgrMouseEvent(int finalChar, int[] intermediates, int intermediateCount)
      Checks if a CSI dispatch represents an SGR mouse event.
      Parameters:
      finalChar - the CSI final character
      intermediates - the intermediate/private-marker characters
      intermediateCount - the number of intermediates
      Returns:
      true if this is an SGR mouse event
    • equals

      public boolean equals(Object o)
      Overrides:
      equals in class Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • toString

      public String toString()
      Overrides:
      toString in class Object