MouseMessage values that your update() method receives like any other message. You choose the reporting mode — cell-level motion, all-motion, or disabled — and the runtime handles the rest.
Enabling mouse support
Return a mouse-enable message frominit() to activate reporting when the program starts, or return it from update() to toggle at runtime.
Command:
EnableMouseAllMotionMessage reports the cursor position on every mouse move, which lets you implement hover effects. EnableMouseCellMotionMessage only fires while a button is held, which is lighter on bandwidth and enough for drag-selection.The MouseMessage type
Every mouse event arrives as aMouseMessage with the following fields:
MouseAction
MouseButton
Handling mouse events in update()
Match onMouseMessage in your update() method alongside other message types. The example below tracks drag-selection: it records start coordinates on press, extends the selection during motion, and clears the active flag on release.
Hit testing
Comparemouse.column() and mouse.row() against the bounds of a rendered region to detect hover or click:
Row and column positions are 0-based after TUI4J normalizes the raw escape sequence coordinates.
Scroll wheel
Scroll events set the button to one of the four wheel values whilegetAction() is MouseActionPress. Use isWheel() for a quick check:
Disabling mouse on exit
ReturnDisableMouseMessage before quitting to restore the terminal’s default mouse behavior:
Running the program with mouse support
Pass the mouse mode toProgram via the builder methods instead of (or in addition to) returning it from init():
Spring Boot integration
Embed TUI4J in a Spring Boot app
External commands
Launch editors and shells from your TUI