From e87d08a789fd119f66c7a2d08933599cccb04c4e Mon Sep 17 00:00:00 2001 From: Thomas Guimbretiere Date: Wed, 23 Oct 2013 20:39:31 +0200 Subject: [PATCH] Reverse lookup for mouse move & drag. --- mcp/mobius/waila/gui/widgets/LayoutCanvas.java | 8 ++++++-- mcp/mobius/waila/gui/widgets/WidgetBase.java | 17 +++++++++++------ 2 files changed, 17 insertions(+), 8 deletions(-) diff --git a/mcp/mobius/waila/gui/widgets/LayoutCanvas.java b/mcp/mobius/waila/gui/widgets/LayoutCanvas.java index dd9d7f1..60f377d 100644 --- a/mcp/mobius/waila/gui/widgets/LayoutCanvas.java +++ b/mcp/mobius/waila/gui/widgets/LayoutCanvas.java @@ -55,10 +55,14 @@ public class LayoutCanvas extends WidgetBase{ //this.onMouseClick(event); break; case DRAG: - this.onMouseDrag(event); + if (targetWidget != null) + targetWidget.onMouseDrag(event); + //this.onMouseDrag(event); break; case MOVE: - this.onMouseMove(event); + if (targetWidget != null) + targetWidget.onMouseMove(event); + //this.onMouseMove(event); break; case RELEASED: if (targetWidget != null) diff --git a/mcp/mobius/waila/gui/widgets/WidgetBase.java b/mcp/mobius/waila/gui/widgets/WidgetBase.java index f21fd3f..4b1898f 100644 --- a/mcp/mobius/waila/gui/widgets/WidgetBase.java +++ b/mcp/mobius/waila/gui/widgets/WidgetBase.java @@ -204,19 +204,24 @@ public abstract class WidgetBase implements IWidget { @Override public void onMouseDrag(MouseEvent event) { //System.out.printf("%s %s\n", this, event); + if (this.parent != null) + this.parent.onMouseDrag(event); - IWidget widget = this.getWidgetAtCoordinates(event.x, event.y); - if (widget != null && widget != this) - widget.onMouseDrag(event); + //IWidget widget = this.getWidgetAtCoordinates(event.x, event.y); + //if (widget != null && widget != this) + // widget.onMouseDrag(event); } @Override public void onMouseMove(MouseEvent event) { //System.out.printf("%s %s\n", this, event); + if (this.parent != null) + this.parent.onMouseMove(event); - IWidget widget = this.getWidgetAtCoordinates(event.x, event.y); - if (widget != null && widget != this) - widget.onMouseMove(event); + + //IWidget widget = this.getWidgetAtCoordinates(event.x, event.y); + //if (widget != null && widget != this) + // widget.onMouseMove(event); } @Override