mirror of
https://github.com/ppy/osu.git
synced 2025-01-13 07:22:54 +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
|
||||
{
|
||||
// will restore the previous text value on failure.
|
||||
Current.TriggerChange();
|
||||
// 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.
|
||||
Current.TriggerChange();
|
||||
};
|
||||
|
||||
Current.BindValueChanged(val =>
|
||||
|
@ -65,18 +65,19 @@ namespace osu.Game.Screens.Edit.Timing
|
||||
{
|
||||
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);
|
||||
}
|
||||
catch
|
||||
{
|
||||
// will restore the previous text value on failure.
|
||||
beatLengthBindable.TriggerChange();
|
||||
}
|
||||
}
|
||||
catch
|
||||
{
|
||||
// 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.BindValueChanged(val =>
|
||||
|
Loading…
Reference in New Issue
Block a user