[Lazarus] How can i mask an input on dbedit? Maskedit not ready!

Bart bartjunk64 at gmail.com
Wed Oct 7 01:07:17 CEST 2009


There is also a bug there.

First:
When setting text, spaces are not translated to BlankChar ('_' by default)

Second:
In Delphi setting text behaves different in how it treats mask
literals depending on wether MaskNoSave is defined in the mask.

Consider trying to set the following text:
'ABC EFGHIJK'

EditMask: '999.999'  -> Text becomes "ABC.___"
(in fact it stops as soon as it encounters a literal that does not fit)

EditMask '999.999;0;_' -> Text becomes "ABC. EFGHIJK"
Note that it just skips literals and goes on filling in the text,
which is correct since all maskliterals are removed in GetText also.
(Also note that the Text property now exceeds the length of the mask,
and it cannot be corrected, which is a definite bug in my D3)

If you define ! in the Editmask along with MaskNosave, it fills text
from the last character.

I will try and fix TCustomMaskEdit.SetText to
1. use FBlankChar for spaces in Text
2. handle FMaskSave = False to keep on filling after the occurrence of
maskliterals

(You could post a bugreport on the bugtracker stating that setting
MaskEdit.Text does not correctly handle MaskNoSave in EditMask. I'll
assign that to me then, so I won't forget)

I have one question for you.
Do you have to use MaskNoSave in the EditMask?
Probably the database you're using is legacy and you can't alter, but
if it's a new project consider not having MaskNoSave in your EditMask,
since it is probably unsafe in Delphi (as my experiment above has
shown).

One remark:
> editmask: '000\.000\.000\-00;0;_'
There is no need to escape the period's or the hyphen, only predefined
maskcharacters need to be escape in order to include them as a literal
in the mask.

Bye,

Bart




More information about the Lazarus mailing list