diff --git a/src/client/spark/view/Controls/PriceEntryControl.xaml.cs b/src/client/spark/view/Controls/PriceEntryControl.xaml.cs index 6836fd703..39da66530 100644 --- a/src/client/spark/view/Controls/PriceEntryControl.xaml.cs +++ b/src/client/spark/view/Controls/PriceEntryControl.xaml.cs @@ -57,16 +57,17 @@ namespace mbts.ui.spark { (o, v) => o._update_text(v), (o, v) => { o._raw_value = v; - if (!o._spec.HasValue || DoubleHelper.IsNaNOrInfinity(v)) + if ((!o._spec.HasValue && o._tick is null) || DoubleHelper.IsNaNOrInfinity(v)) return v; // Note: the decimal cast here is important bc double-rounding errors can cause the keyboard text to conflict with poorly rounded result, and negate Tick Up/Down commands. // This happens bc the tick up/down commands flush the current text before inc/decrementing. - double tick = (double)o._spec.Value.round_to_tick((decimal)v); - if (MathUtils.epsilon_equals(tick, v)) { + var v_dec = (decimal)v; + var rounded = (double)(o._tick?.round_to_tick(v_dec) ?? o._spec.Value.round_to_tick(v_dec)); + if (MathUtils.epsilon_equals(rounded, v)) { // this value has already been rounded, don't make it re-enter the CoerceValueCallback delegate. return v; } - return tick; + return rounded; }, double.NaN); @@ -179,18 +180,13 @@ namespace mbts.ui.spark { if (_text != null) _price_text_gate.try_update(() => { if (_tick is not null) { - var settings = new TickDisplaySettings { - show_decimal_part = true, - show_zero_integer = true, - display_multiplier = 1, - show_commas = false, - nan_text = string.Empty - }; + var settings = TickDisplaySettings.Default; + settings.tick_factors = _tick.get_tick_for(v); _text.Text = _tick.format(v, settings); return; } _text.Text = _spec.HasValue ? _spec.Value.format(v, double.NaN, false, string.Empty) : v.ToString(); - }); + }); } void _update_value() =>