Registriert seit: 15. Mär 2007
4.093 Beiträge
Delphi 12 Athens
|
AW: Android BackButton..
27. Jul 2017, 12:37
Probier mal das ...
Delphi-Quellcode:
// Processes the KeyUp in Forms, to standard behaviour of Android Back key
function Form_KeyUp_Back(const AForm : TCustomForm; var Key: Word; var KeyChar: Char; Shift: TShiftState; bCanTerminate : Boolean) : Boolean;
{$IF DEFINED(ANDROID) or DEFINED(IOS) }
var
FService : IFMXVirtualKeyboardService;
{$ENDIF DEFINED(ANDROID) or DEFINED(IOS) }
begin
Result := False;
//V3
if Key = vkHardwareBack then
begin
{$IF DEFINED(ANDROID) or DEFINED(IOS) }
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;
Result := True;
// Back button pressed, keyboard not visible or not supported on this platform,
// lets exit the app... if condition is met
// !! Mobile apps cannot be terminated
if bCanTerminate then
begin
end;
end;
{$ENDIF DEFINED(ANDROID) or DEFINED(IOS) }
end;
end;
procedure TMain_Frm.FormKeyUp(Sender: TObject; var Key: Word;
var KeyChar: Char; Shift: TShiftState);
begin
{$IFDEF ANDROID}
if Form_KeyUp_Back(Self, Key, KeyChar, Shift, True) then
begin
if TabControlHeader.ActiveTab <> TabItemH1ViewEntry then
begin
....
end else
begin
// May Finish the main Form here, w/o closing it
View_Hide;
end;
Exit;
end;
{$ENDIF ANDROID}
if Key = vkReturn then
begin
end;
end;
Rollo
|
|
Zitat
|