LCL-CustomDrawn-Cocoa: Fixes the alphanumerical key input

git-svn-id: trunk@37158 -
This commit is contained in:
sekelsenmat 2012-05-05 09:21:12 +00:00
parent 1cd734692e
commit 5b94ac9513
2 changed files with 25 additions and 5 deletions

View File

@ -429,7 +429,9 @@ var
begin begin
//inherited keyDown(theEvent); Don't call inherited or else Cocoa will think you didn't handle the event and beep on key input //inherited keyDown(theEvent); Don't call inherited or else Cocoa will think you didn't handle the event and beep on key input
lKey := MacKeyCodeToLCLKey(theEvent, lSendKey, lSendChar, lUTF8Char); lKey := MacKeyCodeToLCLKey(theEvent, lSendKey, lSendChar, lUTF8Char);
//DebugLn('[TCocoaForm] KeyDown='+IntToHex(theEvent.keyCode(), 4)); {$ifdef VerboseCDKeyInput}
DebugLn(Format('[TCocoaForm] KeyDown CocoaKeyCode=%x UTF8Char=%s', [theEvent.keyCode(), lUTF8Char]));
{$endif}
if lSendKey then CallbackKeyDown(WindowHandle, lKey); if lSendKey then CallbackKeyDown(WindowHandle, lKey);
if lSendChar then CallbackKeyChar(WindowHandle, 0, lUTF8Char); if lSendChar then CallbackKeyChar(WindowHandle, 0, lUTF8Char);
end; end;
@ -565,17 +567,34 @@ begin
if Length(charactersIgnoringModifiers) = 1 then if Length(charactersIgnoringModifiers) = 1 then
begin begin
case charactersIgnoringModifiers[1] of case charactersIgnoringModifiers[1] of
'a'..'z': Result:=VK_A+ord(charactersIgnoringModifiers[1])-ord('a'); 'a'..'z':
'A'..'Z': Result:=ord(charactersIgnoringModifiers[1]); begin
Result:=VK_A+ord(charactersIgnoringModifiers[1])-ord('a');
AUTF8Char := charactersIgnoringModifiers;
end;
'A'..'Z':
begin
Result:=ord(charactersIgnoringModifiers[1]);
AUTF8Char := charactersIgnoringModifiers;
end;
#27 : Result:=VK_ESCAPE; #27 : Result:=VK_ESCAPE;
#8 : Result:=VK_BACK; #8 : Result:=VK_BACK;
' ' : Result:=VK_SPACE; ' ' :
begin
Result:=VK_SPACE;
AUTF8Char := charactersIgnoringModifiers;
end;
#13 : Result:=VK_RETURN; #13 : Result:=VK_RETURN;
'0'..'9': Result:=VK_0+ord(charactersIgnoringModifiers[1])-ord('0'); '0'..'9':
begin
Result:=VK_0+ord(charactersIgnoringModifiers[1])-ord('0');
AUTF8Char := charactersIgnoringModifiers;
end;
end; end;
end; end;
if Result<>VK_UNKNOWN then SendKeyUpDown:=true; if Result<>VK_UNKNOWN then SendKeyUpDown:=true;
if AUTF8Char <> '' then SendChar := True;
if Length(characters) > 1 then if Length(characters) > 1 then
begin begin

View File

@ -78,4 +78,5 @@
{.$define VerboseCDAccessibility} {.$define VerboseCDAccessibility}
{.$define VerboseCDClipboard} {.$define VerboseCDClipboard}
{.$define VerboseCDFocus} {.$define VerboseCDFocus}
{.$define VerboseCDKeyInput}