X-Git-Url: http://git.nikiroo.be/?a=blobdiff_plain;f=src%2Fjexer%2FTWidget.java;h=8833f8ff7d0668fb232222ef6fa032a232976be8;hb=b6faeac0d9c3e3ae3376ed28b54ec6ea6408ad7a;hp=22766dde5aa281212c320182fbad09f76c9978f6;hpb=24489803a611e99348e26cadedae1141f48c1a6c;p=fanfix.git diff --git a/src/jexer/TWidget.java b/src/jexer/TWidget.java index 22766dd..8833f8f 100644 --- a/src/jexer/TWidget.java +++ b/src/jexer/TWidget.java @@ -622,7 +622,12 @@ public abstract class TWidget implements Comparable { this.parent = parent; this.window = parent.window; children = new ArrayList(); - parent.addChild(this); + + // Do not add TStatusBars, they are drawn by TApplication + if (this instanceof TStatusBar) { + } else { + parent.addChild(this); + } } /** @@ -642,7 +647,12 @@ public abstract class TWidget implements Comparable { this.parent = parent; this.window = parent.window; children = new ArrayList(); - parent.addChild(this); + + // Do not add TStatusBars, they are drawn by TApplication + if (this instanceof TStatusBar) { + } else { + parent.addChild(this); + } this.x = x; this.y = y; @@ -970,6 +980,29 @@ public abstract class TWidget implements Comparable { } } + /** + * Method that subclasses can override to handle mouse button + * double-clicks. + * + * @param mouse mouse button event + */ + public void onMouseDoubleClick(final TMouseEvent mouse) { + // Default: do nothing, pass to children instead + for (int i = children.size() - 1 ; i >= 0 ; i--) { + TWidget widget = children.get(i); + if (widget.mouseWouldHit(mouse)) { + // Dispatch to this child, also activate it + activate(widget); + + // Set x and y relative to the child's coordinates + mouse.setX(mouse.getAbsoluteX() - widget.getAbsoluteX()); + mouse.setY(mouse.getAbsoluteY() - widget.getAbsoluteY()); + widget.handleEvent(mouse); + return; + } + } + } + /** * Method that subclasses can override to handle window/screen resize * events. @@ -1062,6 +1095,10 @@ public abstract class TWidget implements Comparable { onMouseMotion(mouse); break; + case MOUSE_DOUBLE_CLICK: + onMouseDoubleClick(mouse); + break; + default: throw new IllegalArgumentException("Invalid mouse event type: " + mouse.getType());