Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow slider bar to take focus and accept keyboard input while not hovered #6390

Merged
merged 8 commits into from
Oct 24, 2024
5 changes: 2 additions & 3 deletions osu.Framework/Graphics/UserInterface/SliderBar.cs
Original file line number Diff line number Diff line change
Expand Up @@ -172,14 +172,13 @@ protected override bool OnDragStart(DragStartEvent e)

protected override void OnDragEnd(DragEndEvent e) => Commit();

public override bool AcceptsFocus => true;

protected override bool OnKeyDown(KeyDownEvent e)
{
if (currentNumberInstantaneous.Disabled)
return false;

if (!IsHovered)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should probably early return if not focused. Pressing left/right randomly in settings can unintentionally change a slider.

return false;

float step = KeyboardStep != 0 ? KeyboardStep : (Convert.ToSingle(currentNumberInstantaneous.MaxValue) - Convert.ToSingle(currentNumberInstantaneous.MinValue)) / 20;
if (currentNumberInstantaneous.IsInteger) step = MathF.Ceiling(step);

Expand Down
Loading