Overview
The training code implements manual virtual keyboard avoidance by tracking FormVirtualKeyboardShown / FormVirtualKeyboardHidden events and manually adjusting a TVertScrollBox content bounds. iOS 16+ and Android 12+ have changed how the system keyboard interacts with app windows, and Delphi 13's FMX runtime has updated virtual keyboard support that makes some of this manual code unnecessary or incorrect.
Background
Current Manual Approach
{$IF DEFINED(ANDROID) OR DEFINED(IOS)}
VKAutoShowMode := TVKAutoShowMode.Always;
VSB.OnCalcContentBounds := CalcContentBoundsProc;
{$ENDIF}
procedure CalcContentBoundsProc(Sender: TObject; var ContentBounds: TRectF);
begin
// Manually adjust bounds based on keyboard height
ContentBounds.Bottom := ContentBounds.Bottom + FKeyboardOffset;
end;
What Changed
- iOS 16:
UIKit now uses the keyboard layout guide (UIKeyboardLayoutGuide) — the system automatically handles layout adjustment if Auto Layout is used. FMX apps don't use Auto Layout directly, but Delphi 13's FMX layer was updated to respond to UIKeyboardLayoutGuide.
- Android 12 (API 31): WindowInsets API (
WindowInsetsController) replaces the older adjustResize/adjustPan approach. The android:windowSoftInputMode setting in the manifest interacts with this new API.
- Delphi 12+: FMX introduced
TVirtualKeyboardState improvements and the IFMXVirtualKeyboardService interface was updated.
The manual CalcContentBoundsProc may double-adjust the layout if Delphi 13's own keyboard avoidance is also active, causing the content to scroll too far.
Files Affected
lab-src/Lab*/forms/formMain.pas (VKAutoShowMode setup, keyboard event handlers)
lab-src/Lab*/frames/uNewEntryFrame.pas (CalcContentBoundsProc)
lab-src/Lab*/AndroidManifest.template.xml (windowSoftInputMode)
Steps to Address
- Test the current keyboard avoidance code against Delphi 13 on both platforms to determine if the manual adjustment is still needed or now conflicts with the framework.
- If Delphi 13 handles keyboard avoidance automatically for
TVertScrollBox, remove or simplify CalcContentBoundsProc.
- If manual handling is still needed, update the bounds calculation to use the
IFMXVirtualKeyboardService.VirtualKeyboardBounds property correctly for the current Delphi 13 API.
- In
AndroidManifest.template.xml, verify the android:windowSoftInputMode value (adjustResize vs adjustNothing) is appropriate for API 31+ behavior.
- Test with gesture navigation (Android 10+ swipe gestures) where the navigation bar is hidden, as keyboard insets behave differently.
- Verify that
TVKAutoShowMode.Always is still the correct mode for the training's use case in Delphi 13.
- Update lab instructions to reflect current best practices for keyboard handling.
Test Plan
Overview
The training code implements manual virtual keyboard avoidance by tracking
FormVirtualKeyboardShown/FormVirtualKeyboardHiddenevents and manually adjusting aTVertScrollBoxcontent bounds. iOS 16+ and Android 12+ have changed how the system keyboard interacts with app windows, and Delphi 13's FMX runtime has updated virtual keyboard support that makes some of this manual code unnecessary or incorrect.Background
Current Manual Approach
What Changed
UIKitnow uses the keyboard layout guide (UIKeyboardLayoutGuide) — the system automatically handles layout adjustment if Auto Layout is used. FMX apps don't use Auto Layout directly, but Delphi 13's FMX layer was updated to respond toUIKeyboardLayoutGuide.WindowInsetsController) replaces the olderadjustResize/adjustPanapproach. Theandroid:windowSoftInputModesetting in the manifest interacts with this new API.TVirtualKeyboardStateimprovements and theIFMXVirtualKeyboardServiceinterface was updated.The manual
CalcContentBoundsProcmay double-adjust the layout if Delphi 13's own keyboard avoidance is also active, causing the content to scroll too far.Files Affected
Steps to Address
TVertScrollBox, remove or simplifyCalcContentBoundsProc.IFMXVirtualKeyboardService.VirtualKeyboardBoundsproperty correctly for the current Delphi 13 API.AndroidManifest.template.xml, verify theandroid:windowSoftInputModevalue (adjustResizevsadjustNothing) is appropriate for API 31+ behavior.TVKAutoShowMode.Alwaysis still the correct mode for the training's use case in Delphi 13.Test Plan