2 * Jexer - Java Text User Interface
4 * License: LGPLv3 or later
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.
10 * Copyright (C) 2015 Kevin Lamonte
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.
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.
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
28 * @author Kevin Lamonte [kevin.lamonte@gmail.com]
34 * This class encapsulates several kinds of mouse input events.
36 public final class TMouseEvent
extends TInputEvent
{
39 * The type of event generated.
43 * Mouse motion. X and Y will have screen coordinates.
48 * Mouse button down. X and Y will have screen coordinates.
53 * Mouse button up. X and Y will have screen coordinates.
59 * Type of event, one of MOUSE_MOTION, MOUSE_UP, or MOUSE_DOWN, or
69 public Type
getType() {
74 * Mouse X - relative coordinates.
88 * Mouse Y - relative coordinates.
102 * Mouse X - absolute screen coordinates.
104 private int absoluteX
;
111 public int getAbsoluteX() {
116 * Mouse Y - absolute screen coordinate.
118 private int absoluteY
;
125 public int getAbsoluteY() {
130 * Mouse button 1 (left button).
132 private boolean mouse1
;
139 public boolean getMouse1() {
144 * Mouse button 2 (right button).
146 private boolean mouse2
;
153 public boolean getMouse2() {
158 * Mouse button 3 (middle button).
160 private boolean mouse3
;
167 public boolean getMouse3() {
172 * Mouse wheel UP (button 4).
174 private boolean mouseWheelUp
;
179 * @return mouseWheelUp
181 public boolean getMouseWheelUp() {
186 * Mouse wheel DOWN (button 5).
188 private boolean mouseWheelDown
;
191 * Get mouseWheelDown.
193 * @return mouseWheelDown
195 public boolean getMouseWheelDown() {
196 return mouseWheelDown
;
202 * @param type the type of event, MOUSE_MOTION, MOUSE_DOWN, or MOUSE_UP
203 * @param x relative column
204 * @param y relative row
205 * @param absoluteX absolute column
206 * @param absoluteY absolute row
207 * @param mouse1 if true, left button is down
208 * @param mouse2 if true, right button is down
209 * @param mouse3 if true, middle button is down
210 * @param mouseWheelUp if true, mouse wheel (button 4) is down
211 * @param mouseWheelDown if true, mouse wheel (button 5) is down
213 public TMouseEvent(final Type type
, final int x
, final int y
,
214 final int absoluteX
, final int absoluteY
,
215 final boolean mouse1
, final boolean mouse2
, final boolean mouse3
,
216 final boolean mouseWheelUp
, final boolean mouseWheelDown
) {
221 this.absoluteX
= absoluteX
;
222 this.absoluteY
= absoluteY
;
223 this.mouse1
= mouse1
;
224 this.mouse2
= mouse2
;
225 this.mouse3
= mouse3
;
226 this.mouseWheelUp
= mouseWheelUp
;
227 this.mouseWheelDown
= mouseWheelDown
;
231 * Make human-readable description of this TMouseEvent.
233 * @return displayable String
236 public String
toString() {
237 return String
.format("Mouse: %s x %d y %d absoluteX %d absoluteY %d 1 %s 2 %s 3 %s DOWN %s UP %s",
240 absoluteX
, absoluteY
,