diff --git a/MLEM.Ui/Elements/Element.cs b/MLEM.Ui/Elements/Element.cs index ebe281b..f9aacbc 100644 --- a/MLEM.Ui/Elements/Element.cs +++ b/MLEM.Ui/Elements/Element.cs @@ -402,17 +402,15 @@ namespace MLEM.Ui.Elements { } } - public Element GetMousedElement() { + public virtual Element GetMousedElement() { if (this.IsHidden || this.IgnoresMouse) return null; - if (!this.Area.Contains(this.MousePos)) - return null; for (var i = this.SortedChildren.Count - 1; i >= 0; i--) { var element = this.SortedChildren[i].GetMousedElement(); if (element != null) return element; } - return this; + return this.Area.Contains(this.MousePos) ? this : null; } protected virtual void InitStyle(UiStyle style) { diff --git a/MLEM.Ui/Elements/Panel.cs b/MLEM.Ui/Elements/Panel.cs index 6470720..82712d0 100644 --- a/MLEM.Ui/Elements/Panel.cs +++ b/MLEM.Ui/Elements/Panel.cs @@ -106,6 +106,13 @@ namespace MLEM.Ui.Elements { base.DrawEarly(time, batch, alpha, blendState, samplerState); } + public override Element GetMousedElement() { + // if overflow is handled, don't propagate mouse checks to hidden children + if (this.scrollOverflow && !this.Area.Contains(this.MousePos)) + return null; + return base.GetMousedElement(); + } + private Rectangle GetRenderTargetArea() { var area = this.ChildPaddedArea; area.X = this.DisplayArea.X;