mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-08-05 10:55:56 +02:00
LCL-CustomDrawn-Android: Fixes a bug which prevented input of numbers in Android 4 and overall improves the key events for all devices
git-svn-id: trunk@37252 -
This commit is contained in:
parent
5faf1db14f
commit
d2843b0d5c
@ -143,7 +143,7 @@ var
|
|||||||
lForm: TCDNonNativeForm;
|
lForm: TCDNonNativeForm;
|
||||||
begin
|
begin
|
||||||
lChar := Cardinal(AChar);
|
lChar := Cardinal(AChar);
|
||||||
{$ifdef VerboseCDEvents}
|
{$ifdef VerboseCDKeyInput}
|
||||||
__android_log_write(ANDROID_LOG_INFO,'lclapp',PChar(
|
__android_log_write(ANDROID_LOG_INFO,'lclapp',PChar(
|
||||||
Format('[LCLOnKey] called AKind=%d AKeyCode=%x AChar=%s', [AKind, AKeyCode, UnicodeToUTF8(lChar)])));
|
Format('[LCLOnKey] called AKind=%d AKeyCode=%x AChar=%s', [AKind, AKeyCode, UnicodeToUTF8(lChar)])));
|
||||||
{$endif}
|
{$endif}
|
||||||
@ -153,12 +153,41 @@ begin
|
|||||||
lKey := CDWidgetset.AndroidKeyCodeToLCLKeyCode(AKeyCode);
|
lKey := CDWidgetset.AndroidKeyCodeToLCLKeyCode(AKeyCode);
|
||||||
|
|
||||||
case AKind of
|
case AKind of
|
||||||
ACTION_DOWN: CallbackKeyDown(lCurForm, lKey);
|
ACTION_DOWN:
|
||||||
-1: // This indicates a key char event
|
begin
|
||||||
|
CallbackKeyDown(lCurForm, lKey);
|
||||||
|
|
||||||
|
// Galaxy Nexus S with Android 4.0 sends numbers only as key down/up events,
|
||||||
|
// it doesn't send them to commit text
|
||||||
|
//
|
||||||
|
// Wildfire with Android 2.2 sends the numbers only to commit text
|
||||||
|
//
|
||||||
|
// So if we get any numbers here, generate KeyPress too
|
||||||
|
case lKey of
|
||||||
|
VK_0..VK_9:
|
||||||
|
begin
|
||||||
|
AUTF8Char := VK2Char(lKey);
|
||||||
|
CallbackKeyChar(lCurForm, lKey, AUTF8Char);
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
// This indicates a key char event, created with commitText
|
||||||
|
// We don't get KeyDown/KeyUp when we get this, so generate them
|
||||||
|
-1:
|
||||||
begin
|
begin
|
||||||
AUTF8Text := UnicodeToUTF8(lChar);
|
AUTF8Text := UnicodeToUTF8(lChar);
|
||||||
AUTF8Char := AUTF8Text;
|
AUTF8Char := AUTF8Text;
|
||||||
|
|
||||||
|
if Length(AUTF8Text) = 1 then
|
||||||
|
begin
|
||||||
|
lKey := Char2VK(AUTF8Text[1]);
|
||||||
|
CallbackKeyDown(lCurForm, lKey);
|
||||||
|
end;
|
||||||
|
|
||||||
CallbackKeyChar(lCurForm, lKey, AUTF8Char);
|
CallbackKeyChar(lCurForm, lKey, AUTF8Char);
|
||||||
|
|
||||||
|
if Length(AUTF8Text) = 1 then
|
||||||
|
CallbackKeyUp(lCurForm, lKey);
|
||||||
end;
|
end;
|
||||||
ACTION_UP:
|
ACTION_UP:
|
||||||
begin
|
begin
|
||||||
|
@ -2962,6 +2962,7 @@ function CS_To_String(CompStyle: Integer): String;
|
|||||||
function HiWord(i: integer): word;
|
function HiWord(i: integer): word;
|
||||||
function LoWord(i: integer): word;
|
function LoWord(i: integer): word;
|
||||||
function Char2VK(C : Char) : Word;
|
function Char2VK(C : Char) : Word;
|
||||||
|
function VK2Char(AVK: Word): Char;
|
||||||
function MathRound(AValue: ValReal): Int64;
|
function MathRound(AValue: ValReal): Int64;
|
||||||
function MulDiv(nNumber, nNumerator, nDenominator: Integer): Integer;
|
function MulDiv(nNumber, nNumerator, nDenominator: Integer): Integer;
|
||||||
function KeyToShortCut(const Key: Word; const Shift: TShiftState): TShortCut;
|
function KeyToShortCut(const Key: Word; const Shift: TShiftState): TShortCut;
|
||||||
@ -2993,6 +2994,16 @@ begin
|
|||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
function VK2Char(AVK: Word): Char;
|
||||||
|
begin
|
||||||
|
case AVK of
|
||||||
|
VK_0..VK_9: Result := chr(ord('0')+AVK-VK_0);
|
||||||
|
VK_A..VK_Z: Result := chr(ord('a')+AVK-VK_A);
|
||||||
|
else
|
||||||
|
Result:='?';
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
|
||||||
function MathRound(AValue: ValReal): Int64; inline;
|
function MathRound(AValue: ValReal): Int64; inline;
|
||||||
begin
|
begin
|
||||||
if AValue >= 0 then
|
if AValue >= 0 then
|
||||||
|
Loading…
Reference in New Issue
Block a user