Class MouseEvent

java.lang.Object
org.jline.terminal.MouseEvent

public class MouseEvent extends Object
Represents a mouse event in a terminal that supports mouse tracking.

The MouseEvent class encapsulates information about mouse actions in a terminal, including the type of event (press, release, move, etc.), which button was involved, any modifier keys that were pressed, and the coordinates where the event occurred.

Mouse events are only available in terminals that support mouse tracking, which can be enabled using Terminal.trackMouse(Terminal.MouseTracking). Once mouse tracking is enabled, mouse events can be read using Terminal.readMouseEvent().

Mouse events include:

  • Pressed - A mouse button was pressed
  • Released - A mouse button was released
  • Moved - The mouse was moved without any buttons pressed
  • Dragged - The mouse was moved with a button pressed
  • Wheel - The mouse wheel was scrolled

Example usage:

 Terminal terminal = TerminalBuilder.terminal();

 // Enable mouse tracking
 if (terminal.hasMouseSupport()) {
     terminal.trackMouse(Terminal.MouseTracking.Normal);

     // Read mouse events
     MouseEvent event = terminal.readMouseEvent();
     System.out.println("Mouse event: type=" + event.getType() +
                        ", button=" + event.getButton() +
                        ", position=" + event.getX() + "," + event.getY());
 }
 
See Also: