
procedure TControlMover.FormVirtualKeyboardHidden(Sender: TObject; KeyboardVisible: Boolean; const Bounds: TRect);
begin
FVKVisible := False;
if Assigned(FSaveProps.Control) then
begin
FSaveProps.Control.AnimateFloat('Position.Y', FSaveProps.Position.Y, 0.1);
FSaveProps.Control.Align := FSaveProps.Align;
end;
end;
procedure TControlMover.FormVirtualKeyboardShown(Sender: TObject; KeyboardVisible: Boolean; const Bounds: TRect);
begin
FVKVisible := True;
FVKBounds := Bounds;
if FocusedControl = nil then
Exit;
DoGetMoveControl;
if Assigned(FSaveProps.Control) then
begin
FSaveProps.Control.Align := TAlignLayout.alNone;
FSaveProps.Position.Y := FSaveProps.Control.Position.Y;
SlideControl;
end;
end;
There is a problem on IOS where the Bounds rectangle is reported incorrectly when in landscape mode. You can get the correct bounds rectangle using code found on this QC entry. Lastly, there is a ScrollableForm demo available from Embarcadero. Here is a sample of the source from the ScrollableForm demo:
procedure TFormMain.FormVirtualKeyboardHidden(Sender: TObject;
KeyboardVisible: Boolean;
const Bounds: TRect);
begin
FKBBounds.Create(0, 0, 0, 0);
FNeedOffset := False;
RestorePosition;
end;
procedure TFormMain.FormVirtualKeyboardShown(Sender: TObject;
KeyboardVisible: Boolean;
const Bounds: TRect);
begin
FKBBounds := TRectF.Create(Bounds);
FKBBounds.TopLeft := ScreenToClient(FKBBounds.TopLeft);
FKBBounds.BottomRight := ScreenToClient(FKBBounds.BottomRight);
UpdateKBBounds;
end;
Head over and get the full source to the TControlMover component and demo.
I have some problems with the “ScrollableForm demo” on a form with TStatusBar.
Now i am using a simple methode:
– Set StatusBar.Height to Keyboard-Height
– Scroll to Edit
procedure TFormMain.FormVirtualKeyboardShown(Sender: TObject; KeyboardVisible: Boolean; const Bounds: TRect);
var LItem: TListBoxItem;
begin
LItem := MyFindSelectedListBoxItem;
if Assigned(LItem) then
begin
StatusBarMain.Height := Bounds.Height;
if MyGetListBoxOfItem(LItem) is TListBox then
with MyGetListBoxOfItem(LItem) as TListBox do
begin
FViewportPosition := ViewportPosition;
ScrollToItem(LItem);
end;
end;
end;
procedure TFormOmAppMain.FormVirtualKeyboardHidden(Sender: TObject; KeyboardVisible: Boolean; const Bounds: TRect);
begin
StatusBarMain.Height := 22;
ListBoxXX.ViewportPosition := FViewportPosition;
end;