8dcaed2778b462a59c407193b76532f0f90040f3
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. Note that
35 * the relative (x,y) ARE MUTABLE: TWidget's onMouse() handlers perform that
36 * update during event dispatching.
38 public final class TMouseEvent
extends TInputEvent
{
41 * The type of event generated.
45 * Mouse motion. X and Y will have screen coordinates.
50 * Mouse button down. X and Y will have screen coordinates.
55 * Mouse button up. X and Y will have screen coordinates.
61 * Type of event, one of MOUSE_MOTION, MOUSE_UP, or MOUSE_DOWN, or
71 public Type
getType() {
76 * Mouse X - relative coordinates.
92 * @param x new relative X value
93 * @see jexer.TWidget#onMouseDown(TMouseEvent mouse)
94 * @see jexer.TWidget#onMouseDown(TMouseEvent mouse)
95 * @see jexer.TWidget#onMouseMotion(TMouseEvent mouse)
97 public void setX(final int x
) {
102 * Mouse Y - relative coordinates.
118 * @param y new relative Y value
119 * @see jexer.TWidget#onMouseDown(TMouseEvent mouse)
120 * @see jexer.TWidget#onMouseDown(TMouseEvent mouse)
121 * @see jexer.TWidget#onMouseMotion(TMouseEvent mouse)
123 public void setY(final int y
) {
128 * Mouse X - absolute screen coordinates.
130 private int absoluteX
;
137 public int getAbsoluteX() {
142 * Mouse Y - absolute screen coordinate.
144 private int absoluteY
;
151 public int getAbsoluteY() {
156 * Mouse button 1 (left button).
158 private boolean mouse1
;
165 public boolean getMouse1() {
170 * Mouse button 2 (right button).
172 private boolean mouse2
;
179 public boolean getMouse2() {
184 * Mouse button 3 (middle button).
186 private boolean mouse3
;
193 public boolean getMouse3() {
198 * Mouse wheel UP (button 4).
200 private boolean mouseWheelUp
;
205 * @return mouseWheelUp
207 public boolean getMouseWheelUp() {
212 * Mouse wheel DOWN (button 5).
214 private boolean mouseWheelDown
;
217 * Get mouseWheelDown.
219 * @return mouseWheelDown
221 public boolean getMouseWheelDown() {
222 return mouseWheelDown
;
228 * @param type the type of event, MOUSE_MOTION, MOUSE_DOWN, or MOUSE_UP
229 * @param x relative column
230 * @param y relative row
231 * @param absoluteX absolute column
232 * @param absoluteY absolute row
233 * @param mouse1 if true, left button is down
234 * @param mouse2 if true, right button is down
235 * @param mouse3 if true, middle button is down
236 * @param mouseWheelUp if true, mouse wheel (button 4) is down
237 * @param mouseWheelDown if true, mouse wheel (button 5) is down
239 public TMouseEvent(final Type type
, final int x
, final int y
,
240 final int absoluteX
, final int absoluteY
,
241 final boolean mouse1
, final boolean mouse2
, final boolean mouse3
,
242 final boolean mouseWheelUp
, final boolean mouseWheelDown
) {
247 this.absoluteX
= absoluteX
;
248 this.absoluteY
= absoluteY
;
249 this.mouse1
= mouse1
;
250 this.mouse2
= mouse2
;
251 this.mouse3
= mouse3
;
252 this.mouseWheelUp
= mouseWheelUp
;
253 this.mouseWheelDown
= mouseWheelDown
;
257 * Make human-readable description of this TMouseEvent.
259 * @return displayable String
262 public String
toString() {
263 return String
.format("Mouse: %s x %d y %d absoluteX %d absoluteY %d 1 %s 2 %s 3 %s DOWN %s UP %s",
266 absoluteX
, absoluteY
,