I found a rather disturbing behaviour of MaskEdit in Delphi (3 Pro).
Try this in Delphi:
MaskEdit1.EditMask := 'ccc-ccc-ccc;1;_'Type in the control so the text in the control becomes "1-2-3-4-5-6" (without the quotes)
(This text is a valid text for this mask)
Observe:
MaskEdit1.Text = "1-2-3-4-5-6" (without the quotes), which is as expected
Now do:
MaskEdit1.Text := MaskEdit1.Text; (disable optimizations!!)
(or do MaskEdi1.Text := '1-2-3-4-5-6';)Expected behaviour:
Nothing changes
Observed behaviour:
Text in the control now is "1__-2__-3-4" (without the quotes)
This seems to me a horrible bug in Delphi (D3 at least) MaskEdit behaviour.
Current Lazarus implementation does not behave like this.
The problem occurs when you set Text that has a MaskLiteral in the text, as soon as it finds one, it skips the remaining text in the control and continues after that MaskLiteral.
(This issue only applies when MaskNoSave is _NOT_ applied to the mask)
This makes saving Text and restoring it in a MaskEdit (or masked DBEdit) unsafe if EditMask contains MaskLiterals!
Can anyone do this experiment in a recent Delphi version to see what happens?
If this behaviour is present in recent Delphi, I fail to see how we should implement TCustomMaskEdit.SetText.
- Doing it like my Delphi is a dangerous bug
- Doing it like current maskedit.pp breaks Delphi compatibility
Bart
