Hellow JoshyFun,
JoshyFun wroteSo your problem is that UTF8Key is not "realtime" modificable as "Key"
in KeyPress event ?
As UTF8Key appears as "var" parameter it looks like a bug to me.
Yes. For me too. And here em my PC, OnKeyPress works normal only for Windows (XP). :(
Show quoted text 6 lines
Meanwhile you can use KeyPress to perform the task converting key to
UTF8, perform the changes needed and them convert back to ansi mode.
This way when UTF8KeyPress accepts changed UTF8Key (if it should do
it) you should simply change the routine position and remove the 2
conversion lines.
In a very simple test, I'm trying this:
[code]
const
CWithAccent: array [0..46] of string = ('?', '?', '?', '?', '?', '?', '?', '?', '?', '?', '?', '?', '?', '?', '?', '?', '?', '?', '?', '?', '?', '?',
'?', '?', '?', '?', '?', '?', '?', '?', '?', '?', '?', '?', '?', '?', '?',
'?', '?', '?', '?', '?', '?', '?', '?', '?', '?');
CWithoutAccent: array [0..46] of string = ('a', 'a', 'a', 'a', 'a',
'e', 'e',
'e', 'e', 'i', 'i', 'i', 'i', 'o', 'o', 'o', 'o', 'o', 'u', 'u', 'u', 'u',
'A', 'A', 'A', 'A', 'A', 'E', 'E', 'E', 'E', 'I', 'I', 'I', 'O', 'O', 'O',
'O', 'O', 'U', 'U', 'U', 'U', 'c', 'C', 'n', 'N');
uses
StrUtils;
procedure TForm1.Edit1KeyPress(Sender: TObject; var Key: char);
begin
Key := StringsReplace(AnsiToUtf8(Key), CWithAccent, CWithoutAccent,
[rfReplaceAll])[1];
end;
[/code]
(Please, see well here: http://pastebin.com/qmu80j74)
But unfortunately is working only on Windows. :(