I made breakpoints at TCustomMaskEdit.TextChanged and Keydown procedure, put a character in the field, and noticed that SetInheritedText procedure set FChangedAllowed to False
I'ld say you didn't get it right.
When you press a (printable) key then the follwing happens:
TCustomMaskedit.KeyPress (not KeyDown) b.t.w. calls TCustomMaskedit.InsertChar, which calls TCustomMaskedit.SetInheritedText (if TCustomMaskedit.CanInsertChar returns true).
TCustomMaskedit.SetInheritedText then first sets the flag FChangeAllowed to true, then sets the text in the control.
This then triggers the TextChanged event to be called, which checks wether FChangeAllowed = True (which it is), and allows the change.
After this we return to TCustomMaskedit.SetInheritedtext, and at this point we set FChangeAllowed to False.
This should be completely independant of the widgetset.
I just tested my MaskEdit program (Lazarus 0.9.31 r29137) using Ububtu 11.02 (GTK2 2.20), and it works like a charm.
What you can do is open maskedit.pp and replace TCustomMaskEdit.InsertChar with the following code
procedure TCustomMaskEdit.InsertChar(Ch : Char);
Var
S : ShortString;
i, SelectionStart, SelectionStop: Integer;
begin
if CanInsertChar(FCursorPos + 1, Ch) then
begin
S := Inherited Text;
debugln('TCustomMaskEdit.InsertChar: Ch = ',Ch,' CanInsertChar = True');
if HasSelection then
begin
//replace slection with blank chars
//don't do this via DeleteChars(True), since it will do an unneccesary
//update of the control and 2 TextChanged's are triggerd for every char we enter
GetSel(SelectionStart, SelectionStop);
for i := SelectionStart + 1 to SelectionStop do S[i] := ClearChar(i);
end;
S[FCursorPos + 1] := Ch;
debugln('TCustomMaskedit.InsertChar: calling SeInheritedText(',S,')');
SetInheritedText(S);
SelectNextChar;
end
else
begin
debugln('TCustomMaskedit.InsertChar: CanInsertChar = False');
//If we have a selection > 1 (and cannot insert) then Delete the selected text: Delphi compatibility
if HasExtSelection then DeleteSelected;
end;
end;
Then rebuild the LCL (clean), build the program and then start it from a console.
Use 'ccccccccccc;1;_' as the EditMask (this should allow you to type any (lower ASCII) char in the control).
Select the control and try to type in it and report the debug output on the console.
(Please also make sure that you did not accidentally set ReadOnly to True for the MaskEdit component...)
Bart