I've got a Part derived from TypeSpecificBase<decimal> whose Value I'm trying to constrain between two values. I've overridden CoerceValue like so:
On the face of it, this works. The Value of the part is kept between Maximum and Minimum. However, this doesn't adjust the string value that's displayed on the screen. I tried overriding OnValueChanged like so:
Which is a bit like how I handle increment and decrement for the spin buttons (which work). And like before, this almost works. The DisplayValue of the part is set correctly and the StringValue looks correct - but the value that's displayed on the screen still isn't adjusted to match.
I've also tried overriding CoerceValue on the part group and edit box that the part is in, which also hasn't affected the value displayed on the screen. Is there some property or method call I'm missing?
protected override decimal CoerceValue(decimal value) {
if (value > this.Maximum)
value = this.Maximum;
else if (value < this.Minimum)
value = this.Minimum;
return value;
}
protected override void OnValueChanged(decimal oldValue, decimal newValue){
base.OnValueChanged(oldValue, newValue);
this.DisplayValue = newValue;
this.CommitChangesToValue(PartValueCommitTriggers.StringValueChange);
}
I've also tried overriding CoerceValue on the part group and edit box that the part is in, which also hasn't affected the value displayed on the screen. Is there some property or method call I'm missing?