Sign in Join

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

Mailing lists / lazarus / 2008-12

MaskEdit: question on how it should behave

5 messages · 2 people · –

Reply by email Subscribe to this list Your subscription

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

Bart

Hi,

I'm currently working on the MaskEdit unit, which is ATM not totally Delphi compatible ;)
Since I only have an ancient Delphi (D3) (on ancient hardware, so I cannnot even run newer versions) I have some questions on the behaviour of MaskEdit in current delphi versions.

Question 1:

If I set the text of a MaskEdit to some value that does not match the mask (e.g. EditMask = '0000' and then MaskEdit.Text := 'ABCD'), in D3 no exception is raised and the text in the control is set. Is this still the case in current Delphi's?
(In Lazarus ATM an Exception is raised if you try to do that)

Question 2:
What does an exclamationmark (!) in a mask actually do. The helptext says it removes leading spaces from the data (what data?) and if no ! is in the mask it removes trailing spaces. In real live I see no effect on either MaskEdit.Text or 3:
In the EditMask you can specify if the mask will be saved as pasrt of the data (again: what data?). For instance, if your EditMask is '000;0;_' then maskdata is not saved (the first 0 after the colon ( ; ) sets this value).
I cannot really figure out what it does. I see noe effect n Text or questions 2 and 3: I could, of course, try and understand the VCL code, but that would probably increase the risk of writing code that is almost identical to the copyrighted VCL code.

Thanks for now.

Bart

Reply by email

Alexander Klenin
to Bart
Bart wrote 7 lines
Question 1: If I set the text of a MaskEdit to some value that does not match the mask (e.g. EditMask = '0000' and then MaskEdit.Text := 'ABCD'), in D3 no exception is raised and the text in the control is set. Is this still the case in current Delphi's? (In Lazarus ATM an Exception is raised if you try to do that)

I am not sure how modern Delphi behaves, but I'd say that Lazarus way is correct here -- this is clearly a programmes's error. OTOH, I think it would be useful to provide a separate function like 'TrySetText' which whould return false instead if saising an exception.

Show quoted text 7 lines
Question 3: In the EditMask you can specify if the mask will be saved as pasrt of the data (again: what data?). For instance, if your EditMask is '000;0;_' then maskdata is not saved (the first 0 after the colon ( ; ) sets this value). I cannot really figure out what it does. I see noe effect n Text or you mask includes non-special characters, those are displayed in

the editor as-is,
e.g. if mask is "000-00-00" and the user enters "1234567", the editor would contain
"123-45-67". Depending on the value of the flag, the actual Text property will contain either "1234567" or "123-45-67".

Alexander S. Klenin

Reply by email

Bart
to Alexander Klenin
I am not sure how modern Delphi behaves, but I'd say that Lazarus way is correct here -- this is clearly a programmes's error. OTOH, I think it would be useful to provide a separate function like 'TrySetText' which whould return false instead if saising an exception.

In D3, D4 and Kylix1 ValidateEdit is only called if either the user presses Enter in the control, or the control looses focus.

I still would like someone to test this in D7 or higher.

Show quoted text 17 lines
> Question 3: > In the EditMask you can specify if the mask will be saved as pasrt of > the data (again: what data?). For instance, if your EditMask is > '000;0;_' then maskdata is not saved (the first 0 after the colon ( ; > ) sets this value). > I cannot really figure out what it does. I see noe effect n Text or > EditText at all. If you mask includes non-special characters, those are displayed in the editor as-is, e.g. if mask is "000-00-00" and the user enters "1234567", the editor would contain "123-45-67". Depending on the value of the flag, the actual Text property will contain either "1234567" or "123-45-67".

Yeah, that should not be so hard to implement.

Thanks,

Bart

Reply by email

Alexander Klenin
to Bart
Bart wrote 9 lines
> I am not sure how modern Delphi behaves, but I'd say that Lazarus > way is correct here -- this is clearly a programmes's error. > OTOH, I think it would be useful to provide a separate function > like 'TrySetText' which whould return false instead if saising an exception. In D3, D4 and Kylix1 ValidateEdit is only called if either the user presses Enter in the control, or the control looses focus. I still would like someone to test this in D7 or higher.

Ok, I tested it -- D7 does the same. Actually, ValidateEdit only fires if the text was modified. (Or always at the design time).

Alexander S. Klenin

Reply by email