X-Git-Url: http://git.nikiroo.be/?a=blobdiff_plain;f=src%2Fjexer%2Fevent%2FTMouseEvent.java;h=496d8bc06422baa3014a95a98ae953f60cd4325e;hb=afdec5e9d0416e1c571f1961572b8ededef81146;hp=e098fa20f3556c98b75579a450d8e6985ced4786;hpb=a2018e9964f6c58742cd1e6dd0a0c63e244a89d6;p=fanfix.git diff --git a/src/jexer/event/TMouseEvent.java b/src/jexer/event/TMouseEvent.java index e098fa2..496d8bc 100644 --- a/src/jexer/event/TMouseEvent.java +++ b/src/jexer/event/TMouseEvent.java @@ -3,7 +3,7 @@ * * The MIT License (MIT) * - * Copyright (C) 2017 Kevin Lamonte + * Copyright (C) 2019 Kevin Lamonte * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), @@ -33,7 +33,11 @@ package jexer.event; * the relative (x,y) ARE MUTABLE: TWidget's onMouse() handlers perform that * update during event dispatching. */ -public final class TMouseEvent extends TInputEvent { +public class TMouseEvent extends TInputEvent { + + // ------------------------------------------------------------------------ + // Constants -------------------------------------------------------------- + // ------------------------------------------------------------------------ /** * The type of event generated. @@ -52,14 +56,107 @@ public final class TMouseEvent extends TInputEvent { /** * Mouse button up. X and Y will have screen coordinates. */ - MOUSE_UP + MOUSE_UP, + + /** + * Mouse double-click. X and Y will have screen coordinates. + */ + MOUSE_DOUBLE_CLICK } + // ------------------------------------------------------------------------ + // Variables -------------------------------------------------------------- + // ------------------------------------------------------------------------ + /** * Type of event, one of MOUSE_MOTION, MOUSE_UP, or MOUSE_DOWN. */ private Type type; + /** + * Mouse X - relative coordinates. + */ + private int x; + + /** + * Mouse Y - relative coordinates. + */ + private int y; + + /** + * Mouse X - absolute screen coordinates. + */ + private int absoluteX; + + /** + * Mouse Y - absolute screen coordinate. + */ + private int absoluteY; + + /** + * Mouse button 1 (left button). + */ + private boolean mouse1; + + /** + * Mouse button 2 (right button). + */ + private boolean mouse2; + + /** + * Mouse button 3 (middle button). + */ + private boolean mouse3; + + /** + * Mouse wheel UP (button 4). + */ + private boolean mouseWheelUp; + + /** + * Mouse wheel DOWN (button 5). + */ + private boolean mouseWheelDown; + + // ------------------------------------------------------------------------ + // Constructors ----------------------------------------------------------- + // ------------------------------------------------------------------------ + + /** + * Public contructor. + * + * @param type the type of event, MOUSE_MOTION, MOUSE_DOWN, or MOUSE_UP + * @param x relative column + * @param y relative row + * @param absoluteX absolute column + * @param absoluteY absolute row + * @param mouse1 if true, left button is down + * @param mouse2 if true, right button is down + * @param mouse3 if true, middle button is down + * @param mouseWheelUp if true, mouse wheel (button 4) is down + * @param mouseWheelDown if true, mouse wheel (button 5) is down + */ + public TMouseEvent(final Type type, final int x, final int y, + final int absoluteX, final int absoluteY, + final boolean mouse1, final boolean mouse2, final boolean mouse3, + final boolean mouseWheelUp, final boolean mouseWheelDown) { + + this.type = type; + this.x = x; + this.y = y; + this.absoluteX = absoluteX; + this.absoluteY = absoluteY; + this.mouse1 = mouse1; + this.mouse2 = mouse2; + this.mouse3 = mouse3; + this.mouseWheelUp = mouseWheelUp; + this.mouseWheelDown = mouseWheelDown; + } + + // ------------------------------------------------------------------------ + // TMouseEvent ------------------------------------------------------------ + // ------------------------------------------------------------------------ + /** * Get type. * @@ -69,11 +166,6 @@ public final class TMouseEvent extends TInputEvent { return type; } - /** - * Mouse X - relative coordinates. - */ - private int x; - /** * Get x. * @@ -95,11 +187,6 @@ public final class TMouseEvent extends TInputEvent { this.x = x; } - /** - * Mouse Y - relative coordinates. - */ - private int y; - /** * Get y. * @@ -121,11 +208,6 @@ public final class TMouseEvent extends TInputEvent { this.y = y; } - /** - * Mouse X - absolute screen coordinates. - */ - private int absoluteX; - /** * Get absoluteX. * @@ -136,9 +218,13 @@ public final class TMouseEvent extends TInputEvent { } /** - * Mouse Y - absolute screen coordinate. + * Set absoluteX. + * + * @param absoluteX the new value */ - private int absoluteY; + public void setAbsoluteX(final int absoluteX) { + this.absoluteX = absoluteX; + } /** * Get absoluteY. @@ -150,9 +236,13 @@ public final class TMouseEvent extends TInputEvent { } /** - * Mouse button 1 (left button). + * Set absoluteY. + * + * @param absoluteY the new value */ - private boolean mouse1; + public void setAbsoluteY(final int absoluteY) { + this.absoluteY = absoluteY; + } /** * Get mouse1. @@ -163,11 +253,6 @@ public final class TMouseEvent extends TInputEvent { return mouse1; } - /** - * Mouse button 2 (right button). - */ - private boolean mouse2; - /** * Get mouse2. * @@ -177,11 +262,6 @@ public final class TMouseEvent extends TInputEvent { return mouse2; } - /** - * Mouse button 3 (middle button). - */ - private boolean mouse3; - /** * Get mouse3. * @@ -191,11 +271,6 @@ public final class TMouseEvent extends TInputEvent { return mouse3; } - /** - * Mouse wheel UP (button 4). - */ - private boolean mouseWheelUp; - /** * Get mouseWheelUp. * @@ -205,11 +280,6 @@ public final class TMouseEvent extends TInputEvent { return mouseWheelUp; } - /** - * Mouse wheel DOWN (button 5). - */ - private boolean mouseWheelDown; - /** * Get mouseWheelDown. * @@ -220,34 +290,14 @@ public final class TMouseEvent extends TInputEvent { } /** - * Public contructor. + * Create a duplicate instance. * - * @param type the type of event, MOUSE_MOTION, MOUSE_DOWN, or MOUSE_UP - * @param x relative column - * @param y relative row - * @param absoluteX absolute column - * @param absoluteY absolute row - * @param mouse1 if true, left button is down - * @param mouse2 if true, right button is down - * @param mouse3 if true, middle button is down - * @param mouseWheelUp if true, mouse wheel (button 4) is down - * @param mouseWheelDown if true, mouse wheel (button 5) is down + * @return duplicate intance */ - public TMouseEvent(final Type type, final int x, final int y, - final int absoluteX, final int absoluteY, - final boolean mouse1, final boolean mouse2, final boolean mouse3, - final boolean mouseWheelUp, final boolean mouseWheelDown) { - - this.type = type; - this.x = x; - this.y = y; - this.absoluteX = absoluteX; - this.absoluteY = absoluteY; - this.mouse1 = mouse1; - this.mouse2 = mouse2; - this.mouse3 = mouse3; - this.mouseWheelUp = mouseWheelUp; - this.mouseWheelDown = mouseWheelDown; + public TMouseEvent dup() { + TMouseEvent mouse = new TMouseEvent(type, x, y, absoluteX, absoluteY, + mouse1, mouse2, mouse3, mouseWheelUp, mouseWheelDown); + return mouse; } /**