1 package com
.googlecode
.lanterna
.input
;
3 import com
.googlecode
.lanterna
.TerminalPosition
;
6 * MouseAction, a KeyStroke in disguise, this class contains the information of a single mouse action event.
8 public class MouseAction
extends KeyStroke
{
9 private final MouseActionType actionType
;
10 private final int button
;
11 private final TerminalPosition position
;
14 * Constructs a MouseAction based on an action type, a button and a location on the screen
15 * @param actionType The kind of mouse event
16 * @param button Which button is involved (no button = 0, left button = 1, middle (wheel) button = 2,
17 * right button = 3, scroll wheel up = 4, scroll wheel down = 5)
18 * @param position Where in the terminal is the mouse cursor located
20 public MouseAction(MouseActionType actionType
, int button
, TerminalPosition position
) {
21 super(KeyType
.MouseEvent
, false, false);
22 this.actionType
= actionType
;
24 this.position
= position
;
28 * Returns the mouse action type so the caller can determine which kind of action was performed.
29 * @return The action type of the mouse event
31 public MouseActionType
getActionType() {
36 * Which button was involved in this event. Please note that for CLICK_RELEASE events, there is no button
37 * information available (getButton() will return 0). The standard xterm mapping is:
39 * <li>No button = 0</li>
40 * <li>Left button = 1</li>
41 * <li>Middle (wheel) button = 2</li>
42 * <li>Right button = 3</li>
43 * <li>Wheel up = 4</li>
44 * <li>Wheel down = 5</li>
46 * @return The button which is clicked down when this event was generated
48 public int getButton() {
53 * The location of the mouse cursor when this event was generated.
54 * @return Location of the mouse cursor
56 public TerminalPosition
getPosition() {
61 public String
toString() {
62 return "MouseAction{actionType=" + actionType
+ ", button=" + button
+ ", position=" + position
+ '}';