[Lazarus] More MaskEdit questions

Bart bartjunk64 at gmail.com
Wed Oct 7 14:09:36 CEST 2009


Hi Gerard,

Thanks for the swift reply.

>  From your previous posts it seems that Delphi's TMaskEdit is pretty buggy.

Yeah, it really seems that way.

>  Would it be too complicated to implement a boolean property switch to
>  decide whether to act like Delphi or to act the way it should ? ;-)

Even "simply" implementing it the way Delphi does is almost impossible.
For instance:
EditMask = "!ccc-ccc-ccc;1;_"
Do Text := "123-456-789zzz"
Resulting text in control: 123-456-zzz

EditMask = "!ccc-ccc-ccc;1;_"
You type in the control so it becomes: "1-2-3__-___"
If you read the Text property, it is "1-2-3  -   " (as expected)
Set Text property to "1-2-3  -   ".
Resulting text in control: "__1-__2-___"
Note that now an entire "3" has gone missing

Now while ! in the editmask does _NOT_ influence reading Text, it
definately influences setting Text.

It seems to work something like this:

If MaskNoSave is _NOT_ in mask

if Value is the text we want to set,
Delphi:
- if you encounter a maskliteral _in Value_ do
   - copy this bit, if ! is in mask then trim left, else trim rigth
   - put this bit of text in
   - in the control, skip to the position after the maskliteral
- repeat until no more text

Current Lazrus interpretation:
- fill in text until you hit a maskliteral _in the control_
- go search for next occurrrence of this literal in Value
  - if it is there, skip to position after literal in Value
  - if it is not there, stop
- repeat until (out of text) or (out of literals in Value) or (Control
is filled)

If MaskNoSave is in mask

Delphi:
- fill left to right or right to left (depending on "!" in mask), skip
literals in control
- continue until out of text

Lazarus (I started implementing this)
- fill left to right or right to left (depending on "!" in mask), skip
literals in control
- continue until (out of text) or (control is filled)

Notice that in this case Delphi continues filling in text even if text
is longer then length of internal mask! This effectively screws up the
control beyond repair.


We can either follow buggy (and almost irreproducable) Delphi
behaviour or prefer data-integirety and handle the situation where
MaskNoSave is not defined in mask, like we currently do, sacrificing
100% Delphi compatibility.

I would appreciate opinions on that.

Bart




More information about the Lazarus mailing list