Delphi Can
Android Geri Tuşu - Baskı Önizleme

+- Delphi Can (https://www.delphican.com)
+-- Forum: Delphi (https://www.delphican.com/forumdisplay.php?fid=3)
+--- Forum: Mobil Platform - FireMonkey (FMX) (https://www.delphican.com/forumdisplay.php?fid=7)
+--- Konu Başlığı: Android Geri Tuşu (/showthread.php?tid=6329)



Android Geri Tuşu - barissagir - 14-10-2021

Merhabalar,

Form kullanırken aşağıdaki geri tuşu kodu çalışıyor ama 

Frame yüklü geri tuşuna basınca program kapanıyor.

procedure TGirisF.FrameKeyUp(Sender: TObject; var Key: Word; var KeyChar: Char;
  Shift: TShiftState);
var
FService: IFMXVirtualKeyboardService;
begin
  if (Key = vkHardwareBack) then
  begin
    TPlatformServices.Current.SupportsPlatformService(IFMXVirtualKeyboardService, IInterface(FService));
    if (FService <> nil) and (TVirtualKeyboardState.Visible in FService.VirtualKeyBoardState) then
        begin
        // Botao back pressionado e teclado visivel...
        // (apenas fecha o teclado)
        end
    else
        begin
        Showmessage(index.ToString);
        Key := 0;
        GirisF.Visible:=False;

        end;
  end;
end;


Nasıl yapmalıyım?


Cvp: Android Geri Tuşu - 41linea41 - 14-10-2021

(14-10-2021, Saat: 16:03)barissagir Adlı Kullanıcıdan Alıntı: Merhabalar,

Form kullanırken aşağıdaki geri tuşu kodu çalışıyor ama 

Frame yüklü geri tuşuna basınca program kapanıyor.

procedure TGirisF.FrameKeyUp(Sender: TObject; var Key: Word; var KeyChar: Char;
  Shift: TShiftState);
var
FService: IFMXVirtualKeyboardService;
begin
  if (Key = vkHardwareBack) then
  begin
    TPlatformServices.Current.SupportsPlatformService(IFMXVirtualKeyboardService, IInterface(FService));
    if (FService <> nil) and (TVirtualKeyboardState.Visible in FService.VirtualKeyBoardState) then
        begin
        // Botao back pressionado e teclado visivel...
        // (apenas fecha o teclado)
        end
    else
        begin
        Showmessage(index.ToString);
        Key := 0;
        GirisF.Visible:=False;

        end;
  end;
end;


Nasıl yapmalıyım?
Merhaba

Frame üzerine açıldığı Parent formuna aynen yazdığınız gibi kullanabilirsiniz. Eklemeniz gereken
TPlatformServices.Current.SupportsPlatformService(IFMXVirtualKeyboardService, IInterface(FService));
    if (FService <> nil) and (TVirtualKeyboardState.Visible in FService.VirtualKeyBoardState) then
        begin
     if Assigned(frBackGround) then
      begin
        frBackGround.DisposeOf;
        frBackGround := nil;
         Key:=0;
         KeyChar:=#0;
        exit;
      end;
...
....
..


Frame Create işlemi :
if Assigned(frBackGround) then
 frBackGround.Release
else begin
 frBackGround := TfrBackGround.Create(frmana);
 frBackGround.Parent := frmana;
 frBackGround.Align:=TAlignLayout.Client;
end;



Android Geri Tuşu - barissagir - 14-10-2021

Cevap icin teşekkür ederim. Yarın deneyeceğim insallah.