mirror of
https://github.com/Ellpeck/MLEM.git
synced 2024-12-25 01:39:23 +01:00
propagate mouse events to children by default, except for panels that handle overflow
This commit is contained in:
parent
72b473dc1d
commit
fac7f2beb0
2 changed files with 9 additions and 4 deletions
|
@ -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) {
|
||||
|
|
|
@ -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;
|
||||
|
|
Loading…
Reference in a new issue