Delphi Firemonkey manage VirtualKeyboard on mobile applications
In Firemonkey you can manage the virtualkeyboard on your mobile applications.
if you need that the keyboard not autoshow in your application when a text box is selected you can add this code:
// uses FMX.Types
// you can set TVKAutoShowMode = (DefinedBySystem, Never, Always);
FMX.Types.VKAutoShowMode :=TVKAutoShowMode.vkasNever;
obviusly to enable the virtual keyboard:
// uses FMX.Types
// you can set TVKAutoShowMode = (DefinedBySystem, Never, Always);
FMX.Types.VKAutoShowMode :=TVKAutoShowMode.DefinedBySystem;
so if you have the virtualkeyboard enabled and you want to hide when and edit control is focused you can use this procedure that i found in stackoverflow AT THIS LINK:
uses
{$IFDEF IOS}
FMX.Forms
{$ENDIF}
{$IFDEF Android}
Androidapi.JNI.Embarcadero,
FMX.Platform.Android,
FMX.Helpers.Android
{$ENDIF};
procedure HideVirtualKeyboard;
{$IFDEF IOS}
begin
try
Screen.ActiveForm.Focused := nil;
except
end;
end;
{$ENDIF}
{$IFDEF Android}
var
TextView: JFMXTextEditorProxy;
begin
try
begin
TextView := MainActivity.getTextEditorProxy;
CallInUIThread(
procedure
begin
TextView.setFocusable(false);
TextView.setFocusableInTouchMode(false);
TextView.showSoftInput(false);
TextView.clearFocus;
TextView.setFocusable(true);
TextView.setFocusableInTouchMode(true);
end);
end
except
end;
end;
{$ENDIF}
ANOTHER WAY IS TO USE THE EMBARCADERO PLATFORMSERVICE:
if TPlatformServices.Current.SupportsPlatformService(IFMXVirtualKeyboardService,Keyboard) then
begin
if TVirtualKeyBoardState.Visible in Keyboard.GetVirtualKeyBoardState then
begin
Keyboard.HideVirtualKeyboard;
end
end;
When you connect a bluethoot or usb barcode reader, or a phisycal keyboard to your Android device, your application never show the virtualkeyboard if you don’t change some settings on Android.
Tho show the virtualkeyboard even you have a barcode scanner connected you need to change this settings:
On Android 5.0
Languages and Input > Current keyboard > Turn “Hardware Show Input Methods” ON
On Android 8.0 and Higher
System > Languages and Input > Physical Keyboard > Turn “Show virtual keyboard” ON
If your system is in Italian go to:
Impostazioni –> Gestione Generale –> Lingua e Inserimento –> Tastiere Fisica –> Mostra tastiera su schermo