1
0
Fork 0
mirror of https://github.com/Ellpeck/MLEM.git synced 2024-11-22 12:58:33 +01:00

propagate mouse events to children by default, except for panels that handle overflow

This commit is contained in:
Ellpeck 2019-08-20 21:41:22 +02:00
parent 72b473dc1d
commit fac7f2beb0
2 changed files with 9 additions and 4 deletions

View file

@ -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) {

View file

@ -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;