Fix UTF8 bug, create first executable JAR file
[jvcard.git] / src / com / googlecode / lanterna / input / MouseAction.java
... / ...
CommitLineData
1package com.googlecode.lanterna.input;
2
3import com.googlecode.lanterna.TerminalPosition;
4
5/**
6 * MouseAction, a KeyStroke in disguise, this class contains the information of a single mouse action event.
7 */
8public class MouseAction extends KeyStroke {
9 private final MouseActionType actionType;
10 private final int button;
11 private final TerminalPosition position;
12
13 /**
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
19 */
20 public MouseAction(MouseActionType actionType, int button, TerminalPosition position) {
21 super(KeyType.MouseEvent, false, false);
22 this.actionType = actionType;
23 this.button = button;
24 this.position = position;
25 }
26
27 /**
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
30 */
31 public MouseActionType getActionType() {
32 return actionType;
33 }
34
35 /**
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:
38 * <ul>
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>
45 * </ul>
46 * @return The button which is clicked down when this event was generated
47 */
48 public int getButton() {
49 return button;
50 }
51
52 /**
53 * The location of the mouse cursor when this event was generated.
54 * @return Location of the mouse cursor
55 */
56 public TerminalPosition getPosition() {
57 return position;
58 }
59
60 @Override
61 public String toString() {
62 return "MouseAction{actionType=" + actionType + ", button=" + button + ", position=" + position + '}';
63 }
64}