uses FMX.VirtualKeyboard, FMX.Platform;
Application.Initialize;
VKAutoShowMode := TVKAutoShowMode.Never;
Application.CreateForm(TForm1, Form1);
Application.Run;
end.
FService: IFMXVirtualKeyboardService;
begin
TPlatformServices.Current.SupportsPlatformService(IFMXVirtualKeyboardService, IInterface(FService));
if (FService <> nil) then
begin
FService.ShowVirtualKeyboard(Edit1);
Edit1.SetFocus;
end;
end;
FService: IFMXVirtualKeyboardService;
begin
TPlatformServices.Current.SupportsPlatformService(IFMXVirtualKeyboardService, IInterface(FService));
if (FService <> nil) then
begin
FService.HideVirtualKeyboard;
Edit1.SetFocus;
end;
end;
In the .dpr set VKAutoShowMode to Never
beginApplication.Initialize;
VKAutoShowMode := TVKAutoShowMode.Never;
Application.CreateForm(TForm1, Form1);
Application.Run;
end.
Show soft keyboard on the form (for example on TEdit.OnEnter event):
varFService: IFMXVirtualKeyboardService;
begin
TPlatformServices.Current.SupportsPlatformService(IFMXVirtualKeyboardService, IInterface(FService));
if (FService <> nil) then
begin
FService.ShowVirtualKeyboard(Edit1);
Edit1.SetFocus;
end;
end;
Hide soft keyboard on the form (Edit1 will be still focused with hidden soft keyboard):
varFService: IFMXVirtualKeyboardService;
begin
TPlatformServices.Current.SupportsPlatformService(IFMXVirtualKeyboardService, IInterface(FService));
if (FService <> nil) then
begin
FService.HideVirtualKeyboard;
Edit1.SetFocus;
end;
end;
轉貼至 https://stackoverflow.com/questions/27402101/how-to-hide-and-again-show-soft-keyboard-while-tedit-is-in-focus-delphi-xe7
沒有留言:
張貼留言