Einzelnen Beitrag anzeigen

Rollo62

Registriert seit: 15. Mär 2007
3.908 Beiträge
 
Delphi 12 Athens
 
#7

AW: Android BackButton..

  Alt 27. Jul 2017, 14:11
Man muss sich nicht auf OnResize verlassen, da gab es zumindest bei mir mal Probleme mit.
Auf den mobilen Platformen gibt es die Orientation-Events, die funktionieren bisher sehr gut.

Ist nur etwas lästig die immer zuzuordnen ...

Delphi-Quellcode:
procedure TS4View_Manager.OrientationChange_Subscribe;
begin

  // Register the Message handler
  //Subscribe to orientation change events in OnCreate or similar
  //
  FOrientationChangedId := TMessageManager.DefaultManager.SubscribeToMessage(
           TOrientationChangedMessage,
           EvOnOrientationChanged
         );

end;
Delphi-Quellcode:
procedure TS4View_Manager.EvOnOrientationChanged(const Sender: TObject;
   const Msg: TMessage);
var
  cmd : TS4Api_SysEvents;
  screenService : IFMXScreenService;

begin
  cmd := TS4Api_SysEvents.TApi.None;

  //
  // Evaluate the OrientationChange Event first
  //
  if Msg <> nil then
  begin

    if TPlatformServices.Current.SupportsPlatformService(IFMXScreenService,
                                                         screenService) then
    begin

      case screenService.GetScreenOrientation of
        TScreenOrientation.Portrait : cmd := TS4Api_SysEvents.OrientationChange_Portrait;
        TScreenOrientation.Landscape : cmd := TS4Api_SysEvents.OrientationChange_Landscape;
        TScreenOrientation.InvertedPortrait : cmd := TS4Api_SysEvents.OrientationChange_PortraitInv;
        TScreenOrientation.InvertedLandscape: cmd := TS4Api_SysEvents.OrientationChange_LandscapeInv;
      end;

    end;

    screenService := nil; // Release the ServiceIntf

  end;

   .....

end;
Rollo
  Mit Zitat antworten Zitat