Using a TNumberBox control (at least in Windows, probably other platforms too), when I type in a new value, and then press a button (TButton) to save the changes, upon reading the TNumberBox.Value property, it's returning the original value before the edit was made. It turns out, this value is not accessible until after the control loses focus.
Now the button used to save changes, I have deliberately disabled its CanFocus property, along with all buttons in my app. This is because with the style I use (Jet), a focused button looks horrible (black text on dark gray background). Not to mention, on mobile platforms, focus is practically useless in my case.
Otherwise, if I don't disable CanFocus on this save button, the focus is properly taken off of the TNumberBox and its Value property is okay. But, when disabling CanFocus on the save button, the focus is never taken off of this control, and therefore reading its Value property returns the old value.
How can I ensure the Value property returns the correct new value without changing the save button to CanFocus?
Enabling KillFocusOnReturn is not useful, because users would have to be aware they need to press "Return" or "Enter" which is not an option.
NOTE
This problem also persists if you were to utilize the TNumberBox.OnChangeTracking event. I'm not sure how this event would be useful if you can't even read the new value.
I just discovered a dirty work-around at least. Enable the button's
CanFocusproperty, then on button click, the very first thing that happens should be setting the focus back to theTNumberBoxcontrol. That would both allow focus to be taken off of the control (thus refreshing the value), while also taking the focus away from the button (thus avoiding the terrible look).This however would not be suitable if one were to be utilizing
TNumberBox.OnChangeTrackingand reading theValuefrom within there.