From 91c2f66ef49c23fa1d6fa5ad263b5a1fd9c158cf Mon Sep 17 00:00:00 2001 From: Niki Roo Date: Tue, 4 Jul 2017 07:59:28 +0200 Subject: [PATCH] Widgets: fix Z-Order on up/down mouse events --- src/jexer/TWidget.java | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) 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); -- 2.27.0