From 75f7bbd2f964b6af6930f421a21134b0bea31529 Mon Sep 17 00:00:00 2001 From: Ellpeck Date: Mon, 12 Aug 2019 19:46:43 +0200 Subject: [PATCH] made scroll bars only work when the mouse is in their parent --- MLEM.Ui/Elements/ScrollBar.cs | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/MLEM.Ui/Elements/ScrollBar.cs b/MLEM.Ui/Elements/ScrollBar.cs index 8121f23..3463c07 100644 --- a/MLEM.Ui/Elements/ScrollBar.cs +++ b/MLEM.Ui/Elements/ScrollBar.cs @@ -43,9 +43,12 @@ namespace MLEM.Ui.Elements { public override void Update(GameTime time) { base.Update(time); - var scroll = this.Input.LastScrollWheel - this.Input.ScrollWheel; - if (scroll != 0) - this.CurrentValue += this.StepPerScroll * Math.Sign(scroll); + var moused = this.System.MousedElement; + if (moused == this.Parent || moused?.Parent == this.Parent) { + var scroll = this.Input.LastScrollWheel - this.Input.ScrollWheel; + if (scroll != 0) + this.CurrentValue += this.StepPerScroll * Math.Sign(scroll); + } } public override void Draw(GameTime time, SpriteBatch batch, float alpha, Point offset) {