[Lazarus] New NumbersOnly property for TCustomEdit (r43678)

Bart bartjunk64 at gmail.com
Sat Jan 11 14:16:49 CET 2014

On 1/11/14, Graeme Geldenhuys <mailinglists at geldenhuys.co.uk> wrote:

> Anyway, back in my VCL and LCL days I used to simply hook a generic
> OnKeyPress event to TEdit and it automatically limited the text box to
> numeric data only. The event handler was something like 2-3 lines of
> code. I could find it if somebody was really interested - oh, and it
> worked on all platforms too.

We've all done that.
Just deny all Keys except ['0..'9',#8] in OnKeyPress.
But it doesn't take care of pasting.
(And it doesn't display the nice balloon message when you try to
enter/paste invalid data.)

You do not need to like it, you do not need to use it.
Feel free to use the more generic solution.
Personally I prefer a TSpinEdit and TFloatSpinEdit (the NumbersOnly
only allows positive integers, you cannot even type a "-" in it, let
alone a decimalseparator.

It was a feature request (and often requested), AND Delphi has this
property also.
And it is easy to implement.
The only reservation I had is that is not cross platform.

But if it is perceived as an unneccesary feauture that should never
have been in Lazarus in the first place, I'll be happy to remove it


More information about the Lazarus mailing list