Delphi-PRAXiS

Delphi-PRAXiS (https://www.delphipraxis.net/forum.php)
-   Cross-Platform-Entwicklung (https://www.delphipraxis.net/91-cross-platform-entwicklung/)
-   -   TMainMenu unter OSX (https://www.delphipraxis.net/176576-tmainmenu-unter-osx.html)

Peter666 14. Sep 2013 10:34

TMainMenu unter OSX
 
Hi,

ich hab mal eine Frage. Bei XE2 musste ich, um den ersten Menüeintrag im Applikationsmenü zu haben folgendes machen:

application.ApplicationMenuItems := mnuMain;
mnuMain.Visible := false;

Wie mache ich das unter XE5?

CHackbart 15. Sep 2013 10:01

AW: TMainMenu unter OSX
 
Mit Bordmitteln geht das nicht wirklich, auch scheinen die Shortcuts zerfriemelt.

Meine Behelfsfunktion schaut so aus (FMX.Platform muss eingebunden sein):

Code:
function ActivateMenu(const Menu: TMainMenu): Boolean;
 var MenuService: IFMXMenuService;
begin
 result := assigned(Menu) and
  TPlatformServices.Current.SupportsPlatformService(IFMXMenuService, IInterface(MenuService));

 if result then
    MenuService.CreateOSMenu(Application.MainForm, Menu);
end;
Ich sollte eventuell erwähnen das das Hauptformular kein Menü haben sollte, sondern entweder ein Unterformular oder ein Datenmodul.

CHackbart 16. Sep 2013 09:59

AW: TMainMenu unter OSX
 
Nachtrag:
Es ist wesentlich sauberer, wenn Du das hier machst:

Delphi-Quellcode:
TMainMenu = class(FMX.Menus.TMainMenu, IItemsContainer)
  protected
    procedure DoRecreateOSMenu(const Form: TCommonCustomForm); override;
  public
    procedure Activate;
  end;

{ TMainMenu }
procedure TMainMenu.Activate;
begin
  IFMXMenuService(TPlatformServices.Current.GetPlatformService(
    IFMXMenuService)).CreateOSMenu(Application.MainForm, Self);
end;

procedure TMainMenu.DoRecreateOSMenu(const Form: TCommonCustomForm);
begin
  { do nothing - Activate method now controls this }
end;
Das ist in abgewandelter Form von hier: http://delphihaven.wordpress.com/category/xe3/page/2/

Christian


Alle Zeitangaben in WEZ +1. Es ist jetzt 15:19 Uhr.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024 by Thomas Breitkreuz