Einzelnen Beitrag anzeigen

mensch72

Registriert seit: 6. Feb 2008
838 Beiträge
 
#2

AW: Android BackButton..

  Alt 27. Jul 2017, 11:36
Delphi-Quellcode:
procedure TfrmPscreen.FormKeyUp(Sender: TObject; var Key: Word; var KeyChar: Char; Shift: TShiftState);
var
  FService : IFMXVirtualKeyboardService;
begin
  if (Key = vkHardwareBack) or (Key = vkHome) then begin
    TPlatformServices.Current.SupportsPlatformService(IFMXVirtualKeyboardService, IInterface(FService));
    if (FService <> nil) and (TVirtualKeyboardState.Visible in FService.VirtualKeyBoardState) then
    begin
      // Back button pressed, keyboard visible, so do nothing...
    end else
    begin
      Key := 0;
      // Back button pressed, keyboard not visible or not supported on this platform, lets exit the app...
      MessageDlg('Exit Application?', TMsgDlgType.mtConfirmation, [TMsgDlgBtn.mbOK, TMsgDlgBtn.mbCancel], -1, OnCloseDialog);
    end;
    Exit;
  end;

  if Key = sgiUpRightLong then begin // Menu button pressed ?
    showmessage(verToolV1);
    Exit;
  end;

end;

procedure TfrmPscreen.OnCloseDialog(Sender: TObject; const AResult: TModalResult);
begin
  if AResult = mrOK then begin
    if Assigned(FrmQscreen) then FrmQscreen.Close;
    if Assigned(FrmPscreen) then FrmPscreen.Close;
    Close;
  end;
end;

da siehst du wie man die "SystemButtons" nutzt, auch der aktuell fast nicht mehr zufindende "Menu" Button ist abfragbar und hier einfach mal eine "VersionInfo"
der BackButton schließt hier nicht sofort, sondern erst wenn es der Nutzer ausdrücklich bestätigt... da kannste aber auch beliebg anderes abhängig vom AppState programmieren

Geändert von mensch72 (27. Jul 2017 um 11:40 Uhr)
  Mit Zitat antworten Zitat