{$IF DEFINED(iOS) or DEFINED(ANDROID)}
var
KeyboardDist : Single;
FKBBounds: TRectF;
Control: TControl;
{$ENDIF}
procedure Tmainform.FormVirtualKeyboardHidden(Sender: TObject; KeyboardVisible: Boolean; const Bounds: TRect);
begin
{$IF DEFINED(iOS) or DEFINED(ANDROID)}
if FocusedControl <> nil then
if ((FocusedControl as TControl).Name = 'OriginText') or ((FocusedControl as TControl).Name = 'DestinationText') then
begin
Control := FindControlByName(SnapInLayout, 'RouteAddresses');
if Assigned(Control) and (Control is TRectangle) then
TRectangle(Control).Height := KeyboardDist;
end;
FKBBounds.Create(0, 0, 0, 0);
{$ENDIF}
end;
procedure Tmainform.FormVirtualKeyboardShown(Sender: TObject; KeyboardVisible: Boolean; const Bounds: TRect);
{$IF DEFINED(iOS) or DEFINED(ANDROID)}
var
Factor : Integer;
{$ENDIF}
begin
{$IF DEFINED(iOS) or DEFINED(ANDROID)}
try
if (Screen.FocusControl <> nil) and (Screen.FocusControl is TMemo) then
FocusedControl := TControl(Screen.FocusControl);
except
on E:
Exception do
Showmessage(E.Message);
end;
if FocusedControl <> nil then
if (FocusedControl.Name = 'OriginText') or (FocusedControl.Name = 'DestinationText') then
begin
FKBBounds := TRectF.Create(Bounds);
FKBBounds.TopLeft := ScreenToClient(FKBBounds.TopLeft);
FKBBounds.BottomRight := ScreenToClient(FKBBounds.BottomRight);
Control := FindControlByName(SnapInLayout, 'RouteAddresses');
if FocusedControl.Name = 'OriginText' then
Factor := 2
else
Factor := 1;
if Assigned(Control) and (Control is TRectangle) then
if Height - (FocusedControl.LocalToAbsolute(PointF(0, 0)).Y + FocusedControl.Height * Factor + 5)
< FKBBounds.Height then
begin
KeyboardDist := TRectangle(Control).Height;
TRectangle(Control).Height := TRectangle(Control).Height + (FKBBounds.Height -
(Height - (FocusedControl.LocalToAbsolute(PointF(0, 0)).Y +
FocusedControl.Height * Factor + 5)));
end;
end;
{$ENDIF}
end;