1
0
mirror of https://github.com/ppy/osu.git synced 2025-03-23 18:10:01 +08:00

Correctly block scroll events when hovering controls

This commit is contained in:
Dean Herbert 2018-06-13 16:46:27 +09:00
parent 2cc7953421
commit 2a18625b2c

View File

@ -177,12 +177,13 @@ namespace osu.Game.Overlays.Volume
{
float amount = adjust_step * direction;
var mouse = GetContainingInputManager().CurrentState.Mouse;
if (mouse.HasPreciseScroll)
// handle the case where the OnPressed action was actually a mouse wheel.
// this allows for precise wheel handling.
var state = GetContainingInputManager().CurrentState;
if (state.Mouse?.ScrollDelta.Y != 0)
{
float scrollDelta = mouse.ScrollDelta.Y;
if (scrollDelta != 0)
amount *= Math.Abs(scrollDelta / 10);
OnScroll(state);
return;
}
Volume += amount;
@ -205,6 +206,14 @@ namespace osu.Game.Overlays.Volume
return false;
}
protected override bool OnScroll(InputState state)
{
double amount = adjust_step * state.Mouse.ScrollDelta.Y * (state.Mouse.HasPreciseScroll ? 0.5f : 1);
Volume += Math.Sign(amount) * Math.Max(0.01, Math.Abs(amount));
return true;
}
public bool OnReleased(GlobalAction action) => false;
private const float transition_length = 500;