mirror of
https://github.com/ppy/osu.git
synced 2025-01-28 02:02:53 +08:00
Ensure textbox always reverts to sane state on out-of-range failures
This commit is contained in:
parent
61e62929ee
commit
e0a0902a15
@ -54,9 +54,12 @@ namespace osu.Game.Screens.Edit.Timing
|
|||||||
}
|
}
|
||||||
catch
|
catch
|
||||||
{
|
{
|
||||||
// will restore the previous text value on failure.
|
// TriggerChange below will restore the previous text value on failure.
|
||||||
Current.TriggerChange();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// This is run regardless of parsing success as the parsed number may not actually trigger a change
|
||||||
|
// due to bindable clamping. Even in such a case we want to update the textbox to a sane visual state.
|
||||||
|
Current.TriggerChange();
|
||||||
};
|
};
|
||||||
|
|
||||||
Current.BindValueChanged(val =>
|
Current.BindValueChanged(val =>
|
||||||
|
@ -65,18 +65,19 @@ namespace osu.Game.Screens.Edit.Timing
|
|||||||
{
|
{
|
||||||
if (!isNew) return;
|
if (!isNew) return;
|
||||||
|
|
||||||
if (double.TryParse(Current.Value, out double doubleVal))
|
|
||||||
{
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
if (double.TryParse(Current.Value, out double doubleVal) && doubleVal > 0)
|
||||||
beatLengthBindable.Value = beatLengthToBpm(doubleVal);
|
beatLengthBindable.Value = beatLengthToBpm(doubleVal);
|
||||||
}
|
}
|
||||||
catch
|
catch
|
||||||
{
|
{
|
||||||
// will restore the previous text value on failure.
|
// TriggerChange below will restore the previous text value on failure.
|
||||||
|
}
|
||||||
|
|
||||||
|
// This is run regardless of parsing success as the parsed number may not actually trigger a change
|
||||||
|
// due to bindable clamping. Even in such a case we want to update the textbox to a sane visual state.
|
||||||
beatLengthBindable.TriggerChange();
|
beatLengthBindable.TriggerChange();
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
beatLengthBindable.BindValueChanged(val =>
|
beatLengthBindable.BindValueChanged(val =>
|
||||||
|
Loading…
Reference in New Issue
Block a user