unit Unit1;

interface

uses
  System.SysUtils, System.Types, System.UITypes, System.Classes, System.Variants,
  FMX.Types, FMX.Controls, FMX.Forms, FMX.Dialogs, DPF.iOS.BaseControl,
  DPF.iOS.UITextField, DPF.iOS.UIScrollView, DPF.iOS.UIView;

type
  TForm1 = class( TForm )
    DPFUIScrollView1: TDPFUIScrollView;
    DPFTextField1: TDPFTextField;
    DPFTextField2: TDPFTextField;
    DPFTextField3: TDPFTextField;
    procedure FormVirtualKeyboardHidden( Sender: TObject; KeyboardVisible: Boolean; const Bounds: TRect );
    procedure FormVirtualKeyboardShown( Sender: TObject; KeyboardVisible: Boolean; const Bounds: TRect );
    procedure DPFTextField1BeginEditing( Sender: TObject; isBeginEditing: Boolean );
    procedure DPFTextField2BeginEditing( Sender: TObject; isBeginEditing: Boolean );
    procedure DPFTextField3BeginEditing( Sender: TObject; isBeginEditing: Boolean );
  private
    { Private declarations }

    FKBBounds     : TRectF;
    FocusedControl: TControl;

  protected
    { Protected declarations }
    procedure PaintRects( const UpdateRects: array of TRectF );
  public
    { Public declarations }
  end;

var
  Form1: TForm1;

implementation

{$R *.fmx}

procedure TForm1.DPFTextField1BeginEditing( Sender: TObject; isBeginEditing: Boolean );
begin
  FocusedControl := Sender as TControl;
end;

procedure TForm1.DPFTextField2BeginEditing( Sender: TObject; isBeginEditing: Boolean );
begin
  FocusedControl := Sender as TControl;
end;

procedure TForm1.DPFTextField3BeginEditing( Sender: TObject; isBeginEditing: Boolean );
begin
  FocusedControl := Sender as TControl;
end;

procedure TForm1.FormVirtualKeyboardHidden( Sender: TObject; KeyboardVisible: Boolean; const Bounds: TRect );
begin
  FKBBounds.Create( 0, 0, 0, 0 );
  DPFUIScrollView1.RestoreFromFocused(FKBBounds);
end;

procedure TForm1.FormVirtualKeyboardShown( Sender: TObject; KeyboardVisible: Boolean; const Bounds: TRect );
begin
  Application.ProcessMessages;
  FKBBounds             := TRectF.Create( Bounds );
  FKBBounds.TopLeft     := ScreenToClient( FKBBounds.TopLeft );
  FKBBounds.BottomRight := ScreenToClient( FKBBounds.BottomRight );

  DPFUIScrollView1.ScrollToFocused( FocusedControl, FKBBounds, 0 );
end;

procedure TForm1.PaintRects( const UpdateRects: array of TRectF );
begin
  { }
end;

end.
