mirror of https://github.com/ppy/osu
Use `BindValueChanged` instead of setting the value in property setter
This commit is contained in:
parent
0cceef8da5
commit
3d19364a71
|
@ -20,22 +20,18 @@ private sealed class NumberControl : CompositeDrawable, IHasCurrentValue<int?>
|
|||
{
|
||||
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 @@ public NumberControl()
|
|||
|
||||
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