Prevent children from recieving extra mouse events

This commit is contained in:
Grim Maple 2022-10-08 22:26:51 +03:00
parent 91fbca984e
commit b05d5a6126
2 changed files with 6 additions and 6 deletions
src/dlangui
platforms/common
widgets

View File

@ -1129,12 +1129,12 @@ class Window : CustomEventTarget {
// only route mouse events to visible widgets // only route mouse events to visible widgets
if (root.visibility != Visibility.Visible) if (root.visibility != Visibility.Visible)
return false; return false;
if (!root.isPointInside(event.x, event.y)) if (!root.isPointInside(event.pos))
return false; return false;
// offer event to children first // offer event to children first
for (int i = 0; i < root.childCount; i++) { for (int i = 0; i < root.childCount; i++) {
Widget child = root.child(i); Widget child = root.child(i);
if (dispatchMouseEvent(child, event, cursorIsSet)) if (child.isPointInside(event.pos) && dispatchMouseEvent(child, event, cursorIsSet))
return true; return true;
} }

View File

@ -663,9 +663,9 @@ public:
} }
/// returns true if point is inside of this widget /// returns true if point is inside of this widget
bool isPointInside(int x, int y) { bool isPointInside(int x, int y) { return _pos.isPointInside(x, y); }
return _pos.isPointInside(x, y); ///
} bool isPointInside(Point pt) { return isPointInside(pt.x, pt.y); }
/// return true if state has State.Enabled flag set /// return true if state has State.Enabled flag set
@property bool enabled() { return (state & State.Enabled) != 0; } @property bool enabled() { return (state & State.Enabled) != 0; }