Hello!
The "LAMW and KeyPress" issue has already been discussed:
https://forum.lazarus.freepascal.org/index.php/topic,46596.msg332472.html#msg332472But how to prevent or override the input of unwanted characters into the jEditText component was not touched upon.
On Windows it can be solved like this:procedure TForm1.Edit1OnKeyPress (Sender: TObject; var Key: char);
begin
if (Key in ['A' .. 'F', 'a' .. 'f', '0' .. '9', '', # 8]) = false then Key: = Chr (0);
end;
In LAMW, I tried to do this:procedure TAndroidModule1.jEditText1Changed (Sender: TObject; txt: string;
count: integer);
begin
if count> 0 then
if (txt [count] in ['A' .. 'F', 'a' .. 'f', '0' .. '9', '', # 8]) = false then begin
SetLength (txt, count-1);
jEditText1.Text: = txt;
end;
end;
But after entering a forbidden character, the cursor jumps to the beginning of the line. Also, this method does not prevent the entry of prohibited characters in the middle or at the beginning of the line.
In principle, it is possible to check and delete prohibited characters anywhere in the string in a loop, this is not a problem. But I can't decide how to hold the cursor at the end of the line.
Does LAMW have a nicer way to solve this problem, or at least the ability to control the position of the cursor?