XylemFlow 8 Posted November 12, 2023 When I select all the text in a TNumberBox (Ctrl+A or drag over the text) and hit Delete, the value gets reset to the Min value and the OnChange event is triggered. This is strange because clicking at the end of the number text and deleting all the characters one at a time until none are left doesn't do the same. A user is likely to want to quickly delete the text, type in a new value and hit enter. However, this doesn't work because the value automatically gets reset to the Min value when all the text is deleted at once. Is there any way I can prevent that? Note that I am running for Windows 32-bit. Share this post Link to post
Achim Kalwa 61 Posted November 12, 2023 I can not confirm with TNumberbox (VCL) ; both Delphi 11.3 and 12.0: Ctrl+A then Delete clear the edit field; and I can type the new value. Which are your values for MinValue and MaxValue? Any non-default property settings? Share this post Link to post
XylemFlow 8 Posted November 12, 2023 (edited) I've not tried VCL, only FMX. Interesting that it's not happening in VCL though. Also, I'm using 11.2. I have some boxes ranging from -360 to 360, some from -180 to 180 and some from 0 to 100. They all behave the same way. Edited November 13, 2023 by XylemFlow Share this post Link to post
Mike Warren 2 Posted November 12, 2023 I just tried a FMX NumberBox in D11.3 and D12 and find it a complete mess. Nothing about the operation is intuitive. In addition to your observation, if I try to highlight the text by clicking and dragging, any vertical mouse movement at all changes the value wildly. Ctrl+A does not work for me. Personally, I'd do my own thing and forget TNumberBox completely. Share this post Link to post
XylemFlow 8 Posted November 13, 2023 Thanks Mike. Setting VertIncrement to 0 solves the first issue. I have also set HorzIncrement to 0 so that dragging selects the text without changing the value. Unfortunately that means that the arrow keys and mouse wheel no longer increment the value, but I was able to implement that myself using the KeyDown and MouseWheel events. So yes, it is a bit of a mess, but otherwise it works ok. One advantage is that it automatically prevents non numeric characters and supports copy and paste. Ctrl+A does work for me. Share this post Link to post
XylemFlow 8 Posted November 14, 2023 It seems that this isn't only an issue with TNumberBox. TSpinBox does it too. I think anything descended from TCustomEdit. My best guess is that the control is validated when deleting selected text because there is no caret shown. Share this post Link to post