More MaskEdit questions lazarus / 8-Other ---------------------------------------------------------------------- Bart · 2009-10-07 10:17 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 ---------------------------------------------------------------------- DougNettleton · 2009-10-08 18:46 Bart: Delphi 6 appears to work, like you're reporting Delphi 3 to work, if I create the mask you describe and then type text in the "Masked Text Editor".  But come on, you're saying you want to "Save Literal Characters" and then you're entering literal characters of your own. other than where they appear in the mask. Delphi and for some Mask Characters in Lazarus e.g. ',' and '.' encountering mask character literals in the "input stream" are interpreted to mean "jump to the first character after the mask literal".  This is the behaviour you're seeing here. I noticed this in Lazarus when I couldn't enter the periods(.) of "A.B.C. Electric" in a search field with the mask ">cccccccccc" and generated a bug report - now fixed and closed. I just tried your mask out in Lazarus Windows 32 bit 0.9.29 with FPC 2.3.1 from 2009-09-10 nightly snapshot and I think the way it's working is far better than Delphi 6.  I wouldn't in this case be too concerned with maintaining compatibility with Delphi, since I consider this Delphi behaviour kind of flaky and when I've encountered it in the past I've worked around it. I'm having a hard time trying to imagine when anyone would want the behaviour your seeing in Delphi. HTH, Doug ---------------------------------------------------------------------- Bart · 2009-10-08 22:03 Hi Doug, Quote from: DougNettleton on October 08, 2009, 08:46:58 pmDelphi 6 appears to work, like you're reporting Delphi 3 to work, if I create the mask you describe and then type text in the "Masked Text Editor". This seems to still be true in D2007, so I'm told. QuoteDelphi and for some Mask Characters in Lazarus e.g. ',' and '.' encountering mask character literals in the "input stream" are interpreted to mean "jump to the first character after the mask literal".  This is the behaviour you're seeing here. AFAIK jumping only occurs in the case of period or comma in Delphi, so it should not apply to the given example. QuoteI noticed this in Lazarus when I couldn't enter the periods(.) of "A.B.C. Electric" in a search field with the mask ">cccccccccc" and generated a bug report - now fixed and closed. The person who implemented that in the first time forgot to check if the char was insertable (CanInsertChar), so It was an easy fix for me. Until then I wasn't even aware of this jumping at all  QuoteI just tried your mask out in Lazarus Windows 32 bit 0.9.29 with FPC 2.3.1 from 2009-09-10 nightly snapshot and I think the way it's working is far better than Delphi 6.  Thanks. Quote... I consider this Delphi behaviour kind of flaky and when I've encountered it in the past I've worked around it.Someone put it to me like this: "Volgens mij werkt hij prima zoals hij bedacht is, maar is ie gewoon niet prima bedacht." which roughly translates to: "I think it works fine in the way it was designed, it just wasn't designed very nicely" I believe that if a text is valid in the control, you should be able to set it via Text property. In Delphi it is impossible to set the Text to "1-2-___-___" with EditMask = "ccc-ccc-ccc;1;_", even though it is a perfectly valid text. In the real world ot MaskEdit usage, probably the scenario above is not very interesting. In most programs the user is supposed to type in the control, and it seems that the Lazarus implementation works (almost?) identical in that way. So I tend to leave it like that for the moment. OTOH I have no idea if it affects DBEdit controls with a mask (I don't do databases at all). Thanks for the input, Bart