mirror of
https://github.com/ppy/osu.git
synced 2025-01-28 06:03:08 +08:00
Use BindValueChanged
instead of setting the value in property setter
This commit is contained in:
parent
0cceef8da5
commit
3d19364a71
@ -20,22 +20,18 @@ namespace osu.Game.Overlays.Settings
|
||||
{
|
||||
private readonly BindableWithCurrent<int?> current = new BindableWithCurrent<int?>();
|
||||
|
||||
private readonly OutlinedNumberBox numberBox;
|
||||
|
||||
public Bindable<int?> Current
|
||||
{
|
||||
get => current;
|
||||
set
|
||||
{
|
||||
current.Current = value;
|
||||
numberBox.Text = value.Value.ToString();
|
||||
}
|
||||
get => current.Current;
|
||||
set => current.Current = value;
|
||||
}
|
||||
|
||||
public NumberControl()
|
||||
{
|
||||
AutoSizeAxes = Axes.Y;
|
||||
|
||||
OutlinedNumberBox numberBox;
|
||||
|
||||
InternalChildren = new[]
|
||||
{
|
||||
numberBox = new OutlinedNumberBox
|
||||
@ -55,13 +51,11 @@ namespace osu.Game.Overlays.Settings
|
||||
|
||||
current.Value = value;
|
||||
});
|
||||
}
|
||||
|
||||
protected override void Update()
|
||||
{
|
||||
base.Update();
|
||||
if (Current.Value == null)
|
||||
numberBox.Current.Value = "";
|
||||
Current.BindValueChanged(e =>
|
||||
{
|
||||
numberBox.Current.Value = e.NewValue?.ToString();
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user