X-Git-Url: http://git.nikiroo.be/?a=blobdiff_plain;f=src%2Fjexer%2Fevent%2FTMouseEvent.java;h=253d8b60cbec29a36339a698fad0d62a5a3c744b;hb=daa4106c096cd4d2b92c3cbae6491edccd25fcc4;hp=09ace1da0d97a20ff925857ad0b288c5b1be34e4;hpb=7b5261bc5b641e0769902f014e3b21f61050b02b;p=fanfix.git diff --git a/src/jexer/event/TMouseEvent.java b/src/jexer/event/TMouseEvent.java index 09ace1d..253d8b6 100644 --- a/src/jexer/event/TMouseEvent.java +++ b/src/jexer/event/TMouseEvent.java @@ -1,4 +1,4 @@ -/** +/* * Jexer - Java Text User Interface * * License: LGPLv3 or later @@ -31,9 +31,11 @@ package jexer.event; /** - * This class encapsulates several kinds of mouse input events. + * This class encapsulates several kinds of mouse input events. Note that + * the relative (x,y) ARE MUTABLE: TWidget's onMouse() handlers perform that + * update during event dispatching. */ -public class TMouseEvent extends TInputEvent { +public final class TMouseEvent extends TInputEvent { /** * The type of event generated. @@ -56,63 +58,198 @@ public class TMouseEvent extends TInputEvent { } /** - * Type of event, one of MOUSE_MOTION, MOUSE_UP, or MOUSE_DOWN, or - * KEYPRESS. + * Type of event, one of MOUSE_MOTION, MOUSE_UP, or MOUSE_DOWN. + */ + private Type type; + + /** + * Get type. + * + * @return type */ - public Type type; + public Type getType() { + return type; + } /** * Mouse X - relative coordinates. */ - public int x; + private int x; + + /** + * Get x. + * + * @return x + */ + public int getX() { + return x; + } + + /** + * Set x. + * + * @param x new relative X value + * @see jexer.TWidget#onMouseDown(TMouseEvent mouse) + * @see jexer.TWidget#onMouseDown(TMouseEvent mouse) + * @see jexer.TWidget#onMouseMotion(TMouseEvent mouse) + */ + public void setX(final int x) { + this.x = x; + } /** * Mouse Y - relative coordinates. */ - public int y; + private int y; + + /** + * Get y. + * + * @return y + */ + public int getY() { + return y; + } + + /** + * Set y. + * + * @param y new relative Y value + * @see jexer.TWidget#onMouseDown(TMouseEvent mouse) + * @see jexer.TWidget#onMouseDown(TMouseEvent mouse) + * @see jexer.TWidget#onMouseMotion(TMouseEvent mouse) + */ + public void setY(final int y) { + this.y = y; + } /** * Mouse X - absolute screen coordinates. */ - public int absoluteX; + private int absoluteX; + + /** + * Get absoluteX. + * + * @return absoluteX + */ + public int getAbsoluteX() { + return absoluteX; + } /** * Mouse Y - absolute screen coordinate. */ - public int absoluteY; + private int absoluteY; + + /** + * Get absoluteY. + * + * @return absoluteY + */ + public int getAbsoluteY() { + return absoluteY; + } /** * Mouse button 1 (left button). */ - public boolean mouse1; + private boolean mouse1; + + /** + * Get mouse1. + * + * @return mouse1 + */ + public boolean isMouse1() { + return mouse1; + } /** * Mouse button 2 (right button). */ - public boolean mouse2; + private boolean mouse2; + + /** + * Get mouse2. + * + * @return mouse2 + */ + public boolean isMouse2() { + return mouse2; + } /** * Mouse button 3 (middle button). */ - public boolean mouse3; + private boolean mouse3; + + /** + * Get mouse3. + * + * @return mouse3 + */ + public boolean isMouse3() { + return mouse3; + } /** * Mouse wheel UP (button 4). */ - public boolean mouseWheelUp; + private boolean mouseWheelUp; + + /** + * Get mouseWheelUp. + * + * @return mouseWheelUp + */ + public boolean isMouseWheelUp() { + return mouseWheelUp; + } /** * Mouse wheel DOWN (button 5). */ - public boolean mouseWheelDown; + private boolean mouseWheelDown; + + /** + * Get mouseWheelDown. + * + * @return mouseWheelDown + */ + public boolean isMouseWheelDown() { + return mouseWheelDown; + } /** * 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) { - this.type = type; + 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; } /** @@ -121,7 +258,7 @@ public class TMouseEvent extends TInputEvent { * @return displayable String */ @Override - public final String toString() { + public String toString() { return String.format("Mouse: %s x %d y %d absoluteX %d absoluteY %d 1 %s 2 %s 3 %s DOWN %s UP %s", type, x, y,