Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to hide (and again show) soft keyboard while TEdit is in focus DELPHI XE7

Can you help me how to hide (and again show) soft keyboard while TEdit is in focus?

like image 714
pudnivec74 Avatar asked Dec 02 '22 15:12

pudnivec74


1 Answers

I have a solution:

  1. In the .dpr set VKAutoShowMode to Never

    begin
      Application.Initialize;
      VKAutoShowMode := TVKAutoShowMode.Never;
      Application.CreateForm(TForm1, Form1);
      Application.Run;
    end. 
    
  2. Show soft keyboard on the form (for example on TEdit.OnEnter event):

    var
      FService: IFMXVirtualKeyboardService;
    begin
      TPlatformServices.Current.SupportsPlatformService(IFMXVirtualKeyboardService, IInterface(FService));
      if (FService <> nil) then
      begin
        FService.ShowVirtualKeyboard(Edit1);
        Edit1.SetFocus;
      end;
    
  3. Hide soft keyboard on the form (Edit1 will be still focused with hidden soft keyboard):

    var
      FService: IFMXVirtualKeyboardService;
    begin
      TPlatformServices.Current.SupportsPlatformService(IFMXVirtualKeyboardService, IInterface(FService));
      if (FService <> nil) then
      begin
        FService.HideVirtualKeyboard;
        Edit1.SetFocus;
      end;
    
like image 142
pudnivec74 Avatar answered Dec 10 '22 04:12

pudnivec74