Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / lazarus / 2014-01

New NumbersOnly property for TCustomEdit (r43678)

34 messages · 14 people · –

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Bart

Hi,

I have implemented a NumbersOnly property for TCustomEdit in r43678. Currently it only does something on Win32/Win64 and WinCE (the latter one I am unable to test), since these widgetsets have native support for this feature.

It is only available in trunk, and I don't think it'll be in 1.2 release (since it's a new feature sice we released 1.2RC1). ATM it is only published for TEdit (for all other descendants it's public).

I don't know if GTK2, Carbon, Cocoa and QT can support this.

Please test and report bugs in the bugtracker.

Bart

Reply by email

Unknown author
to Bart
Bart wrote 13 lines
Hi, I have implemented a NumbersOnly property for TCustomEdit in r43678. Currently it only does something on Win32/Win64 and WinCE (the latter one I am unable to test), since these widgetsets have native support for this feature. It is only available in trunk, and I don't think it'll be in 1.2 release (since it's a new feature sice we released 1.2RC1). ATM it is only published for TEdit (for all other descendants it's public). I don't know if GTK2, Carbon, Cocoa and QT can support this.

Others can emulate it in keydown and set text, besides that that Qt supports (QLineEdit)
such scenario by using QValidator (QIntValidator) for input evaluation.

z.

Reply by email

Bart
to Unknown author
Show quoted text 5 lines
Others can emulate it in keydown and set text, besides that that Qt supports (QLineEdit) such scenario by using QValidator (QIntValidator) for input evaluation.

Hmm, can we use this to implement NumbersOnly in the QT WS code?

Bart

Reply by email

zeljko
to Bart
Bart wrote 9 lines
On 1/9/14, wrote: > > Others can emulate it in keydown and set text, besides that that Qt > supports (QLineEdit) > such scenario by using QValidator (QIntValidator) for input evaluation. > Hmm, can we use this to implement NumbersOnly in the QT WS code?

Yes, but why we should use any widgetset to implement such property ? Isn't keyDown/SetText enough to implement it in lcl ?

z.

Reply by email

Mailing Lists
Bart wrote
I have implemented a NumbersOnly property for TCustomEdit in r43678.

Confused... Why not just use a MaskEdit widget? Or doesn't LCL have a TMaskedEdit component?
Regards,
Graeme

Reply by email

Michael Van Canneyt
to Mailing Lists
Mailing Lists wrote 8 lines
On Thursday 09/01/2014 at 1:51 pm, Bart wrote: > I have implemented a NumbersOnly property for TCustomEdit in r43678. Confused... Why not just use a MaskEdit widget? Or doesn't LCL have a TMaskedEdit component?

Because Maskedit always does a lot more than just limiting your entry to numbers. Alignment, adding spaces whatnot. Usually in totally unnatural ways

I never liked a maskedit.

Michael.

Reply by email

Graeme Geldenhuys
to Michael Van Canneyt
Michael Van Canneyt wrote
Because Maskedit always does a lot more than just limiting your entry to numbers. Alignment, adding spaces whatnot. Usually in totally unnatural ways

OK, fair enough, but all those can be configured too.

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.

Regards,
- Graeme -

fpGUI Toolkit - a cross-platform GUI toolkit using Free Pascal http://fpgui.sourceforge.net/

Reply by email

Bart
to Mailing Lists: Confused... Why not just use a MaskEdit widget? Or doesn't LCL have a TMaskedEdit…
Mailing Lists wrote
Confused... Why not just use a MaskEdit widget?

Because a masked MaskEdit also limits the number of digits one can enter. And it doesn't look as nice as a simple TEdit.

Personally I would go for a T(Float)SpinEdit rather than a MaskEdit.

Or doesn't LCL have a TMaskedEdit component?

Yes, I rewrote major parts of it in the past, and now maintain it.

Bart

Reply by email

Bart
to Michael Van Canneyt: Because Maskedit always does a lot more than just limiting your entry to numbers.…
Michael Van Canneyt wrote
I never liked a maskedit.

Well, ages ago (as it seems) we didn't have a decent MaskEdit. I needed it and so rewrote major parts of it.
And tried to get rid of some illogical features that the Borland guys introduced.

After I had done that, I realized that Lazarus had a better component for what I wanted to achieve in the first place... (I came from Delphi 3, where such a component was not avaialable at all.)

From TMaskEdit I derived a TTimeEdit control, which I happily use inn

some of my apps.

An edit control that controls input based on a regex, and looking like a simple TEdit, might be a nice feature to have.

Bart

Reply by email

Bart
to Graeme Geldenhuys: OK, fair enough, but all those can be configured too. Anyway, back in my VCL and LCL days…
Graeme Geldenhuys wrote 5 lines
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 again.

Bart

Reply by email

Hans-Peter Diettrich
to Bart: Well, ages ago (as it seems) we didn't have a decent MaskEdit. I needed it and so rewrote…
An edit control that controls input based on a regex, and looking like a simple TEdit, might be a nice feature to have.

I found general masking problems while entering (incomplete) input, and while editing the previous input. Where should the cursor be moved, i.e. which (first) character doesn't match the specification?

IMO the problem boils down to an fault-tolerant parser, that allows to hilite wrong parts of some input, but does not prevent changes in other places, which finally *may* lead to a correct input. Not so obvious with only numerical input, but a big problem with e.g. phone numbers with embedded fixed characters.

The control should allow to hilite individual wrong characters, what's beyond the capabilities of simple edit controls (requires RTF or similar formatting features).

DoDi

Reply by email

Bart
to Hans-Peter Diettrich
Hans-Peter Diettrich wrote
I found general masking problems while entering (incomplete) input, and while editing the previous input. Where should the cursor be moved, i.e. which (first) character doesn't match the specification?

You lost me here.
Which component are you describing here?

Bart

Reply by email

Michael Van Canneyt
to Bart: Well, ages ago (as it seems) we didn't have a decent MaskEdit. I needed it and so rewrote…
Bart wrote 19 lines
On 1/10/14, Michael Van Canneyt wrote: > I never liked a maskedit. > Well, ages ago (as it seems) we didn't have a decent MaskEdit. I needed it and so rewrote major parts of it. And tried to get rid of some illogical features that the Borland guys introduced. After I had done that, I realized that Lazarus had a better component for what I wanted to achieve in the first place... (I came from Delphi 3, where such a component was not avaialable at all.) > From TMaskEdit I derived a TTimeEdit control, which I happily use inn some of my apps. An edit control that controls input based on a regex, and looking like a simple TEdit, might be a nice feature to have.

I am all for this, but I would implement a property RegEx in TEdit itself. Not yet another control.

Michael.

Reply by email

Graeme Geldenhuys
to Bart: Well, ages ago (as it seems) we didn't have a decent MaskEdit. I needed it and so rewrote…
Bart wrote
An edit control that controls input based on a regex, and looking like a simple TEdit, might be a nice feature to have.

Much better idea, but as Michael pointed out, you probably don't need another control for that. Take a look at Qt for a nice example (if I'm not mistaken). They allow you to set an input mask for a standard textedit control. That input mask (validator) may be regex too. This is a lot more powerful that VCL/LCL's MaskEdit or a specialised SpinEdit etc.

But if you guys are anal about "delphi compatibility" like the FPC developers, then that is probably not an option for you.

Regards,
- Graeme -

fpGUI Toolkit - a cross-platform GUI toolkit using Free Pascal http://fpgui.sourceforge.net/

Reply by email

Hans-Peter Diettrich
to Bart: You lost me here. Which component are you describing here? Bart
Show quoted text 8 lines
On 1/11/14, Hans-Peter Diettrich wrote: > I found general masking problems while entering (incomplete) input, and > while editing the previous input. Where should the cursor be moved, i.e. > which (first) character doesn't match the specification? You lost me here. Which component are you describing here?

A new one, that overcomes the problems of the existing ones.

DoDi

Reply by email

Michael Van Canneyt
to Graeme Geldenhuys
Graeme Geldenhuys wrote 6 lines
On 2014-01-11 22:42, Bart wrote: > The compatibility must be that we can compile Delphi code, the other > way around isn't required, Okay, that's a good stance compared to the Free Pascal team.

Eh ?

I don't see how the stance of the FPC team differs ?

There are extensions to basic routines or even extra routines and units in the RTL as well ?

Michael.

Reply by email

Mattias Gaertner
to Michael Van Canneyt
Show quoted text 14 lines
On Sun, 12 Jan 2014, Graeme Geldenhuys wrote: > On 2014-01-11 22:42, Bart wrote: >> The compatibility must be that we can compile Delphi code, the other >> way around isn't required, > > > Okay, that's a good stance compared to the Free Pascal team. Eh ? I don't see how the stance of the FPC team differs ?

I guess he means: The Delphi mode should be back-to-delphi compatible.

Note: A discussion about FPC/Delphi compatibility is better held on the fpc lists. Thanks.

Mattias

Reply by email

Graeme Geldenhuys
to Michael Van Canneyt: Eh ? I don't see how the stance of the FPC team differs ? There are extensions to basic…
Michael Van Canneyt wrote 5 lines
> > Okay, that's a good stance compared to the Free Pascal team. Eh ? I don't see how the stance of the FPC team differs ?

The Lazarus team seems to want to be able to convert and compile Delphi code. Only in one direction.

The Free Pascal team wants Delphi compatibility in both directions. Moving from Delphi to FPC, and then still keep the ability to move back to Delphi. The second part is ridiculous as far as I'm concerned - it limits FPC too much in what it can do, change or improve.

Regards,
- Graeme -

fpGUI Toolkit - a cross-platform GUI toolkit using Free Pascal http://fpgui.sourceforge.net/

Reply by email

William Oliveira Ferreira
to Graeme Geldenhuys

+1

2014/1/13 Graeme Geldenhuys

Show quoted text 30 lines
On 2014-01-12 12:47, Michael Van Canneyt wrote: >> >> Okay, that's a good stance compared to the Free Pascal team. > > Eh ? > I don't see how the stance of the FPC team differs ? The Lazarus team seems to want to be able to convert and compile Delphi code. Only in one direction. The Free Pascal team wants Delphi compatibility in both directions. Moving from Delphi to FPC, and then still keep the ability to move back to Delphi. The second part is ridiculous as far as I'm concerned - it limits FPC too much in what it can do, change or improve. Regards, - Graeme - -- fpGUI Toolkit - a cross-platform GUI toolkit using Free Pascal http://fpgui.sourceforge.net/ -- _______________________________________________ Lazarus mailing list http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus
________________________________ William de Oliveira Ferreira -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.lazarus.freepascal.org/pipermail/lazarus/attachments/20140113/78a4774b/attachment.html>

Reply by email

Michael Van Canneyt
to Graeme Geldenhuys: The Lazarus team seems to want to be able to convert and compile Delphi code. Only in one…
Graeme Geldenhuys wrote 15 lines
On 2014-01-12 12:47, Michael Van Canneyt wrote: >> >> Okay, that's a good stance compared to the Free Pascal team. > > Eh ? > I don't see how the stance of the FPC team differs ? The Lazarus team seems to want to be able to convert and compile Delphi code. Only in one direction. The Free Pascal team wants Delphi compatibility in both directions. Moving from Delphi to FPC, and then still keep the ability to move back to Delphi. The second part is ridiculous as far as I'm concerned - it limits FPC too much in what it can do, change or improve.

No, this is not correct.

The compiler's Delphi mode does attempts to emulate the compiler as much as possible, yes. But other than that, we strive for the same thing as Lazarus: Delphi code should compile.

Michael.

Reply by email

Sven Barth
to Graeme Geldenhuys: The Lazarus team seems to want to be able to convert and compile Delphi code. Only in one…

Am 13.01.2014 20:59 schrieb "Graeme Geldenhuys" <

Show quoted text 17 lines
: On 2014-01-12 12:47, Michael Van Canneyt wrote: >> >> Okay, that's a good stance compared to the Free Pascal team. > > Eh ? > I don't see how the stance of the FPC team differs ? The Lazarus team seems to want to be able to convert and compile Delphi code. Only in one direction. The Free Pascal team wants Delphi compatibility in both directions. Moving from Delphi to FPC, and then still keep the ability to move back to Delphi. The second part is ridiculous as far as I'm concerned - it limits FPC too much in what it can do, change or improve.

Then we wouldn't have mode ObjFPC and the other non-Delphi modes.

Regards,
Sven
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.lazarus.freepascal.org/pipermail/lazarus/attachments/20140113/f6a73f71/attachment.html>

Reply by email

Florian Klämpfl
to Graeme Geldenhuys: The Lazarus team seems to want to be able to convert and compile Delphi code. Only in one…
Show quoted text 12 lines
On 2014-01-12 12:47, Michael Van Canneyt wrote: >> >> Okay, that's a good stance compared to the Free Pascal team. > > Eh ? > I don't see how the stance of the FPC team differs ? The Lazarus team seems to want to be able to convert and compile Delphi code. Only in one direction. The Free Pascal team wants Delphi compatibility in both directions.

Wrong.

Reply by email

Marco van de Voort
to Graeme Geldenhuys: The Lazarus team seems to want to be able to convert and compile Delphi code. Only in one…
Graeme Geldenhuys wrote 5 lines
The Free Pascal team wants Delphi compatibility in both directions. Moving from Delphi to FPC, and then still keep the ability to move back to Delphi. The second part is ridiculous as far as I'm concerned - it limits FPC too much in what it can do, change or improve.

It should be possible to maintain components for both Delphi and FPC at the same time yes, with minimization of ifdefs.

The trouble is that anything else is a lot more difficult than most people think.

Both making _meaningful_ extensions and having them not compromise that compatibility in a practical way.

Exceptions that require codechanges pile on over time, making the question of compatibility academical.

Reply by email

Mattias Gaertner
to Frank Poretzky
Show quoted text 11 lines
Frank Poretzky hat am 22. Januar 2014 um 13:12 geschrieben: On Sat, 11 Jan 2014 13:57:48 +0100, Bart wrote: >Personally I would go for a T(Float)SpinEdit rather than a MaskEdit. Yes, that's the easiest way to control range-bound number input. It just lacks an option to get rid of those spacious up/down elements. Any chance to get that done?

A TSpinEdit without spins elements?
Why not use TEdit?

Mattias

Reply by email

Alexsander Rosa
to Mattias Gaertner

2014/1/22 Mattias Gaertner

Show quoted text 18 lines
> Frank Poretzky hat am 22. Januar 2014 um 13:12 > geschrieben: > > On Sat, 11 Jan 2014 13:57:48 +0100, Bart wrote: > > >Personally I would go for a T(Float)SpinEdit rather than a MaskEdit. > > Yes, that's the easiest way to control range-bound number input. It > just lacks an option to get rid of those spacious up/down elements. > Any chance to get that done? A TSpinEdit without spins elements? Why not use TEdit? Mattias

Frank, are you complaining about the SIZE of the arrows? Maybe you need smaller ones (or a property to set their size). -------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.lazarus.freepascal.org/pipermail/lazarus/attachments/20140122/57681f84/attachment.html>

Reply by email

Frank Poretzky
to Alexsander Rosa
Alexsander Rosa wrote 16 lines
2014/1/22 Mattias Gaertner > > > Frank Poretzky hat am 22. Januar 2014 um 13:12 > > geschrieben: > > > > On Sat, 11 Jan 2014 13:57:48 +0100, Bart wrote: > > > > >Personally I would go for a T(Float)SpinEdit rather than a MaskEdit. > > > > Yes, that's the easiest way to control range-bound number input. It > > just lacks an option to get rid of those spacious up/down elements. > > Any chance to get that done? > > A TSpinEdit without spins elements? > Why not use TEdit?

You're right, that sounds weird. But why extend a TEdit and add Min-/Max-/Value properties including all the logistics behind them to get what the Float-/SpinEdit controls already offer?

Frank, are you complaining about the SIZE of the arrows? Maybe you need smaller ones (or a property to set their size).

Sometimes I'd like to have them completely removed, not in the least to gain space.

Think of a 2-dimensional matrix of numbers, which have to be observed though hardly changed, where it may be disturbing to see all those values separated by spacious arrows.

And for what reason do I need gradual ups and downs when entering a TCP port number, where there's no logical neighborhood between most of them and keyboard usage is the only sufficient way to change a value (SMTP ports: ..25..465..587..65535)? In those frequent cases offering arrows looks like a joke.

A single boolean ShowArrows property or, following your idea, an integer ArrowsWidth property with '0' removing it completely would solve that problem preserving a coherent codebase.

Frank

Reply by email

Frank Poretzky
to Alexsander Rosa: 2014/1/22 Mattias Gaertner Frank, are you complaining about the SIZE of the arrows? Maybe…
Alexsander Rosa wrote 16 lines
2014/1/22 Mattias Gaertner > > > Frank Poretzky hat am 22. Januar 2014 um 13:12 > > geschrieben: > > > > On Sat, 11 Jan 2014 13:57:48 +0100, Bart wrote: > > > > >Personally I would go for a T(Float)SpinEdit rather than a MaskEdit. > > > > Yes, that's the easiest way to control range-bound number input. It > > just lacks an option to get rid of those spacious up/down elements. > > Any chance to get that done? > > A TSpinEdit without spins elements? > Why not use TEdit?

You're right, that sounds weird. But why extend a TEdit and add Min-/Max-/Value properties including all the logistics behind them to get what the Float-/SpinEdit controls already offer?

Frank, are you complaining about the SIZE of the arrows? Maybe you need smaller ones (or a property to set their size).

Sometimes I'd like to have them completely removed, not least to gain space.

Think of a 2-dimensional matrix of numbers, which have to be observed though hardly changed, where it may be disturbing to see all those values separated by spacious arrows.

And for what reason do I need gradual ups and downs when entering a TCP port number, where there's no logical neighborhood between most of them and keyboard usage is the only sufficient way to change a value (SMTP ports: ..25..465..587..65535)? In those frequent cases offering arrows looks like a joke.

A single boolean ShowArrows property or, following your idea, an integer ArrowsWidth property with '0' removing it completely would solve that problem preserving a coherent codebase.

Frank

Reply by email

Unknown author
to Frank Poretzky
Frank Poretzky wrote 42 lines
On Wed, 22 Jan 2014 11:43:49 -0200, Alexsander Rosa wrote: > 2014/1/22 Mattias Gaertner > >> >> > Frank Poretzky hat am 22. Januar 2014 um 13:12 >> > geschrieben: >> > >> > On Sat, 11 Jan 2014 13:57:48 +0100, Bart wrote: >> > >> > >Personally I would go for a T(Float)SpinEdit rather than a MaskEdit. >> > >> > Yes, that's the easiest way to control range-bound number input. It >> > just lacks an option to get rid of those spacious up/down elements. >> > Any chance to get that done? >> >> A TSpinEdit without spins elements? >> Why not use TEdit? You're right, that sounds weird. But why extend a TEdit and add Min-/Max-/Value properties including all the logistics behind them to get what the Float-/SpinEdit controls already offer? > Frank, are you complaining about the SIZE of the arrows? > Maybe you need smaller ones (or a property to set their size). Sometimes I'd like to have them completely removed, not least to gain space. Think of a 2-dimensional matrix of numbers, which have to be observed though hardly changed, where it may be disturbing to see all those values separated by spacious arrows. And for what reason do I need gradual ups and downs when entering a TCP port number, where there's no logical neighborhood between most of them and keyboard usage is the only sufficient way to change a value (SMTP ports: ..25..465..587..65535)? In those frequent cases offering arrows looks like a joke. A single boolean ShowArrows property or, following your idea, an integer ArrowsWidth property with '0' removing it completely would solve that problem preserving a coherent codebase.

It's not "just like that". What widgetsets supports hiding arrows ? Only windows or none ? On the other side we don't have ability to create special TEdit + Arrows which can be hidden (arrows must be child of TEdit), and that's probably possible only with qt and maybe with win32 (gtk2/carbon does not support such things).
IMO, only solution atm is to create your own class eg. TNumberEdit and handle input events so you can discard anything except numbers.

z.

Reply by email

Frank Poretzky
to Unknown author
Show quoted text 29 lines
On 2014-01-22 18:50, Frank Poretzky wrote: > On Wed, 22 Jan 2014 11:43:49 -0200, Alexsander Rosa wrote: > >> 2014/1/22 Mattias Gaertner >> >>> >>> > Frank Poretzky hat am 22. Januar 2014 um 13:12 >>> > geschrieben: >>> > >>> > On Sat, 11 Jan 2014 13:57:48 +0100, Bart wrote: >>> > >>> > >Personally I would go for a T(Float)SpinEdit rather than a MaskEdit. >>> > >>> > Yes, that's the easiest way to control range-bound number input. It >>> > just lacks an option to get rid of those spacious up/down elements. >>> > Any chance to get that done? >>> >>> A TSpinEdit without spins elements? >>> Why not use TEdit? > A single boolean ShowArrows property or, following your idea, an > integer ArrowsWidth property with '0' removing it completely would > solve that problem preserving a coherent codebase. It's not "just like that". What widgetsets supports hiding arrows ? Only windows or none ? On the other side we don't have ability to create special TEdit + Arrows which can be hidden (arrows must be child of TEdit), and that's probably possible only with qt and maybe with win32 (gtk2/carbon does not support such things).

You're right. The arrow elements aren't allowed to be there in the first place. OTOH I don't see an urgent need to support changing visibility of the spinner part during runtime. ...

IMO, only solution atm is to create your own class eg. TNumberEdit and handle input events so you can discard anything except numbers.

... So why not introduce a TCustomEdit based intermediary TCustomFloatEdit class including the SpinEdit's Min-/Max-/Value properties with the related logistics, from which then the TCustomFloatSpinEdit class with the spinner part added derives? That separation would prevent widgetset modifications as well as redundant number filtering code.

Frank

Reply by email