From: Niki Roo Date: Tue, 4 Jul 2017 05:59:28 +0000 (+0200) Subject: Widgets: fix Z-Order on up/down mouse events X-Git-Tag: fanfix-swing-0.0.1~12^2~13^2~266^2 X-Git-Url: https://git.nikiroo.be/?a=commitdiff_plain;h=91c2f66ef49c23fa1d6fa5ad263b5a1fd9c158cf;p=fanfix-swing.git Widgets: fix Z-Order on up/down mouse events --- diff --git a/src/jexer/TWidget.java b/src/jexer/TWidget.java index 9b99c915..d4ec1e2b 100644 --- a/src/jexer/TWidget.java +++ b/src/jexer/TWidget.java @@ -868,7 +868,8 @@ public abstract class TWidget implements Comparable { */ public void onMouseDown(final TMouseEvent mouse) { // Default: do nothing, pass to children instead - for (TWidget widget: children) { + 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); @@ -889,7 +890,8 @@ public abstract class TWidget implements Comparable { */ public void onMouseUp(final TMouseEvent mouse) { // Default: do nothing, pass to children instead - for (TWidget widget: children) { + 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);