1
0
mirror of https://github.com/ppy/osu.git synced 2026-06-01 13:20:11 +08:00

Compare commits

...

2 Commits

4 changed files with 26 additions and 32 deletions
@@ -1,17 +1,17 @@
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence. // Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
// See the LICENCE file in the repository root for full licence text. // See the LICENCE file in the repository root for full licence text.
using osu.Framework.Input;
namespace osu.Game.Graphics.UserInterface namespace osu.Game.Graphics.UserInterface
{ {
public partial class OsuNumberBox : OsuTextBox public partial class OsuNumberBox : OsuTextBox
{ {
protected override bool AllowIme => false;
public OsuNumberBox() public OsuNumberBox()
{ {
InputProperties = new TextInputProperties(TextInputType.Number, false);
SelectAllOnFocus = true; SelectAllOnFocus = true;
} }
protected override bool CanAddCharacter(char character) => char.IsAsciiDigit(character);
} }
} }
@@ -2,7 +2,6 @@
// See the LICENCE file in the repository root for full licence text. // See the LICENCE file in the repository root for full licence text.
using System.Globalization; using System.Globalization;
using osu.Framework.Input;
namespace osu.Game.Graphics.UserInterfaceV2 namespace osu.Game.Graphics.UserInterfaceV2
{ {
@@ -20,11 +19,6 @@ namespace osu.Game.Graphics.UserInterfaceV2
{ {
public bool AllowDecimals { get; init; } public bool AllowDecimals { get; init; }
public InnerNumberBox()
{
InputProperties = new TextInputProperties(TextInputType.Number, false);
}
protected override bool CanAddCharacter(char character) protected override bool CanAddCharacter(char character)
=> char.IsAsciiDigit(character) || (AllowDecimals && CultureInfo.CurrentCulture.NumberFormat.NumberDecimalSeparator.Contains(character)); => char.IsAsciiDigit(character) || (AllowDecimals && CultureInfo.CurrentCulture.NumberFormat.NumberDecimalSeparator.Contains(character));
} }
@@ -5,7 +5,6 @@ using osu.Framework.Bindables;
using osu.Framework.Graphics; using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.UserInterface; using osu.Framework.Graphics.UserInterface;
using osu.Framework.Input;
namespace osu.Game.Overlays.Settings namespace osu.Game.Overlays.Settings
{ {
@@ -67,10 +66,7 @@ namespace osu.Game.Overlays.Settings
private partial class OutlinedNumberBox : OutlinedTextBox private partial class OutlinedNumberBox : OutlinedTextBox
{ {
public OutlinedNumberBox() protected override bool AllowIme => false;
{
InputProperties = new TextInputProperties(TextInputType.Number, false);
}
protected override bool CanAddCharacter(char character) => char.IsAsciiDigit(character); protected override bool CanAddCharacter(char character) => char.IsAsciiDigit(character);
+21 -17
View File
@@ -1176,33 +1176,37 @@ namespace osu.Game.Screens.Select
protected override bool IsDragging => base.IsDragging || absoluteScrolling; protected override bool IsDragging => base.IsDragging || absoluteScrolling;
public bool OnPressed(KeyBindingPressEvent<GlobalAction> e) protected override bool OnMouseDown(MouseDownEvent e)
{ {
switch (e.Action) if (e.Button == MouseButton.Right)
{ {
case GlobalAction.AbsoluteScrollSongList: // The default binding for absolute scroll is right mouse button.
// The default binding for absolute scroll is right mouse button. // To avoid conflicts with context menus, disallow absolute scroll completely if it looks like things will fall over.
// To avoid conflicts with context menus, disallow absolute scroll completely if it looks like things will fall over. if (e.CurrentState.Mouse.Buttons.Contains(MouseButton.Right)
if (e.CurrentState.Mouse.Buttons.Contains(MouseButton.Right) && GetContainingInputManager()!.HoveredDrawables.OfType<IHasContextMenu>().Any())
&& GetContainingInputManager()!.HoveredDrawables.OfType<IHasContextMenu>().Any()) return false;
return false;
ScrollToAbsolutePosition(e.CurrentState.Mouse.Position); ScrollToAbsolutePosition(e.CurrentState.Mouse.Position);
absoluteScrolling = true; absoluteScrolling = true;
return true; return true;
} }
return base.OnMouseDown(e);
}
protected override void OnMouseUp(MouseUpEvent e)
{
absoluteScrolling = false;
base.OnMouseUp(e);
}
public bool OnPressed(KeyBindingPressEvent<GlobalAction> e)
{
return false; return false;
} }
public void OnReleased(KeyBindingReleaseEvent<GlobalAction> e) public void OnReleased(KeyBindingReleaseEvent<GlobalAction> e)
{ {
switch (e.Action)
{
case GlobalAction.AbsoluteScrollSongList:
absoluteScrolling = false;
break;
}
} }
protected override bool OnMouseMove(MouseMoveEvent e) protected override bool OnMouseMove(MouseMoveEvent e)