Commit | Line | Data |
---|---|---|
df8de03f KL |
1 | /** |
2 | * Jexer - Java Text User Interface | |
3 | * | |
df8de03f KL |
4 | * License: LGPLv3 or later |
5 | * | |
7b5261bc KL |
6 | * This module is licensed under the GNU Lesser General Public License |
7 | * Version 3. Please see the file "COPYING" in this directory for more | |
8 | * information about the GNU Lesser General Public License Version 3. | |
df8de03f KL |
9 | * |
10 | * Copyright (C) 2015 Kevin Lamonte | |
11 | * | |
12 | * This program is free software; you can redistribute it and/or | |
13 | * modify it under the terms of the GNU Lesser General Public License | |
14 | * as published by the Free Software Foundation; either version 3 of | |
15 | * the License, or (at your option) any later version. | |
16 | * | |
17 | * This program is distributed in the hope that it will be useful, but | |
18 | * WITHOUT ANY WARRANTY; without even the implied warranty of | |
19 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
20 | * General Public License for more details. | |
21 | * | |
22 | * You should have received a copy of the GNU Lesser General Public | |
23 | * License along with this program; if not, see | |
24 | * http://www.gnu.org/licenses/, or write to the Free Software | |
25 | * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA | |
26 | * 02110-1301 USA | |
7b5261bc KL |
27 | * |
28 | * @author Kevin Lamonte [kevin.lamonte@gmail.com] | |
29 | * @version 1 | |
df8de03f KL |
30 | */ |
31 | package jexer.event; | |
32 | ||
33 | /** | |
34 | * This class encapsulates several kinds of mouse input events. | |
35 | */ | |
36 | public class TMouseEvent extends TInputEvent { | |
37 | ||
7b5261bc KL |
38 | /** |
39 | * The type of event generated. | |
40 | */ | |
b1589621 | 41 | public enum Type { |
7b5261bc KL |
42 | /** |
43 | * Mouse motion. X and Y will have screen coordinates. | |
44 | */ | |
45 | MOUSE_MOTION, | |
46 | ||
47 | /** | |
48 | * Mouse button down. X and Y will have screen coordinates. | |
49 | */ | |
50 | MOUSE_DOWN, | |
51 | ||
52 | /** | |
53 | * Mouse button up. X and Y will have screen coordinates. | |
54 | */ | |
55 | MOUSE_UP | |
df8de03f KL |
56 | } |
57 | ||
58 | /** | |
59 | * Type of event, one of MOUSE_MOTION, MOUSE_UP, or MOUSE_DOWN, or | |
7b5261bc | 60 | * KEYPRESS. |
df8de03f KL |
61 | */ |
62 | public Type type; | |
63 | ||
64 | /** | |
7b5261bc | 65 | * Mouse X - relative coordinates. |
df8de03f KL |
66 | */ |
67 | public int x; | |
68 | ||
69 | /** | |
7b5261bc | 70 | * Mouse Y - relative coordinates. |
df8de03f KL |
71 | */ |
72 | public int y; | |
73 | ||
74 | /** | |
7b5261bc | 75 | * Mouse X - absolute screen coordinates. |
df8de03f KL |
76 | */ |
77 | public int absoluteX; | |
78 | ||
79 | /** | |
7b5261bc | 80 | * Mouse Y - absolute screen coordinate. |
df8de03f KL |
81 | */ |
82 | public int absoluteY; | |
83 | ||
84 | /** | |
7b5261bc | 85 | * Mouse button 1 (left button). |
df8de03f KL |
86 | */ |
87 | public boolean mouse1; | |
88 | ||
89 | /** | |
7b5261bc | 90 | * Mouse button 2 (right button). |
df8de03f KL |
91 | */ |
92 | public boolean mouse2; | |
93 | ||
94 | /** | |
7b5261bc | 95 | * Mouse button 3 (middle button). |
df8de03f KL |
96 | */ |
97 | public boolean mouse3; | |
98 | ||
99 | /** | |
7b5261bc | 100 | * Mouse wheel UP (button 4). |
df8de03f KL |
101 | */ |
102 | public boolean mouseWheelUp; | |
103 | ||
104 | /** | |
7b5261bc | 105 | * Mouse wheel DOWN (button 5). |
df8de03f KL |
106 | */ |
107 | public boolean mouseWheelDown; | |
108 | ||
109 | /** | |
7b5261bc | 110 | * Public contructor. |
df8de03f KL |
111 | * |
112 | * @param type the type of event, MOUSE_MOTION, MOUSE_DOWN, or MOUSE_UP | |
113 | */ | |
7b5261bc KL |
114 | public TMouseEvent(final Type type) { |
115 | this.type = type; | |
df8de03f KL |
116 | } |
117 | ||
118 | /** | |
7b5261bc KL |
119 | * Make human-readable description of this TMouseEvent. |
120 | * | |
121 | * @return displayable String | |
df8de03f KL |
122 | */ |
123 | @Override | |
7b5261bc KL |
124 | public final String toString() { |
125 | return String.format("Mouse: %s x %d y %d absoluteX %d absoluteY %d 1 %s 2 %s 3 %s DOWN %s UP %s", | |
126 | type, | |
127 | x, y, | |
128 | absoluteX, absoluteY, | |
129 | mouse1, | |
130 | mouse2, | |
131 | mouse3, | |
132 | mouseWheelUp, | |
133 | mouseWheelDown); | |
df8de03f KL |
134 | } |
135 | ||
136 | } |