Lazarus seems to use CN_CHAR message for onKeyPress. Look up TWinControl in controls.pas and wincontrol.inc.
TWinControl.CNChar() sends to DoKeyPress(). Seems pretty complicated process to me and there was no documentation for CN_CHAR.
Backspace is very simple... if key number is VK_BACK then text:=copy(text,1,length(text)-1);
At least if not allowing cursor moving to the middle of text, or selecting part of text. I'm afraid for graphical application all funtionality of TEdit has to be coded by self.
If you can simulate onKeyPress event by some means there is some hints from my UI class:
Code:
// note: caretPos is a property with built in limitations to value range.
procedure TUIEdit.KeyPress(c: char);
var l: integer;
begin
if byte(c)>31 then begin
FText:=UTF8toSys(FText);
l:=length(FText);
SetText(SysToUTF8(copy(FText,1,caretPos)+c+copy(FText,caretPos+1,l-caretPos)));
caretPos:=caretPos+1;
end;
end;
procedure TUIEdit.KeyDown(key: word; shift: TShiftState);
var l,p: integer;
begin
l:=length(text);
case byte(key) of
VK_LEFT: caretPos:=caretPos-1;
VK_RIGHT: caretPos:=caretPos+1;
VK_HOME: caretPos:=0;
VK_END: caretPos:=l;
VK_DELETE:
if (caretPos<l) and (l>0) then begin
FText:=UTF8toSys(FText);
SetText(SysToUTF8(copy(text,1,caretPos)+copy(text,caretPos+2,l-caretPos)));
end;
VK_BACK:
if caretPos>0 then begin
p:=caretPos; caretPos:=caretPos-1;
FText:=UTF8toSys(FText);
SetText(SysToUTF8(copy(text,1,p-1)+copy(text,p+1,l-p)));
end;
VK_RETURN: Focused:=false;
end;
end;
Bookmarks