Application Menu

Mac OSX specific forum
coco2
Enthusiast
Enthusiast
Posts: 461
Joined: Mon Nov 25, 2013 5:38 am
Location: Australia

Application Menu

Post by coco2 »

About and settings menus seem to be greyed out, does anyone know how to enable them?
Wolfram
Enthusiast
Enthusiast
Posts: 604
Joined: Thu May 30, 2013 4:39 pm

Re: Application Menu

Post by Wolfram »

Code: Select all

Global mainWindow

Enumeration MenuItems
  #menuItem1
  #menuItem2
EndEnumeration


Procedure main()
  mainWindow = OpenWindow(#PB_Any, 0, 0, 450, 160, "", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
  
  If CreateMenu(0, WindowID(mainWindow))    ;-Menüs...
    MenuItem(#PB_Menu_About, "About")
    MenuItem(#PB_Menu_Preferences, "Preferences")
    
    MenuTitle("myMenu")
    MenuItem(#menuItem1, "Open"  +#TAB$+"Cmd+O")
    MenuItem(#menuItem2, "Save"  +#TAB$+"Cmd+S")
  EndIf
  
EndProcedure


Procedure windowEvents(event)
  Select event
    Case #PB_Event_CloseWindow
      ProcedureReturn #False
      
    Case #PB_Event_Menu
      Select EventMenu()
        Case #PB_Menu_About
          Debug "About"
          
        Case #PB_Menu_Preferences
          Debug "Preferences"
          
        Case #menuItem1
          Debug "Open"
        Case #menuItem2
          Debug "Save"
          
          
        Case #PB_Menu_Quit
          ProcedureReturn #False
      EndSelect
      
    Case #PB_Event_Gadget
      Select EventGadget()
          
          
      EndSelect
  EndSelect
  ProcedureReturn #True
EndProcedure



main()

Repeat
  event = WaitWindowEvent()
Until windowEvents(event) = #False
macOS Catalina 10.15.7
coco2
Enthusiast
Enthusiast
Posts: 461
Joined: Mon Nov 25, 2013 5:38 am
Location: Australia

Re: Application Menu

Post by coco2 »

Thanks I got it working
coco2
Enthusiast
Enthusiast
Posts: 461
Joined: Mon Nov 25, 2013 5:38 am
Location: Australia

Re: Application Menu

Post by coco2 »

I have a problem with the Quit event. It is always available even when a requester is active. When you click on quit it has to wait until the requester has been closed. Is there any way to close the requester using the quit menu?
User avatar
Mindphazer
Enthusiast
Enthusiast
Posts: 460
Joined: Mon Sep 10, 2012 10:41 am
Location: Savoie

Re: Application Menu

Post by Mindphazer »

Can you post your code ?
MacBook Pro 16" M4 Pro - 24 Gb - MacOS 15.4.1 - Iphone 15 Pro Max - iPad at home
...and unfortunately... Windows at work...
coco2
Enthusiast
Enthusiast
Posts: 461
Joined: Mon Nov 25, 2013 5:38 am
Location: Australia

Re: Application Menu

Post by coco2 »

I found a solution:

Code: Select all

Procedure CallbackQuit()
  CloseWindow(#PB_All)
  Quit = 1
EndProcedure
CompilerIf #PB_Compiler_OS = #PB_OS_MacOS
  BindMenuEvent(0, #PB_Menu_Quit, @CallbackQuit())
CompilerEndIf
Quit needs to be a global I think.
coco2
Enthusiast
Enthusiast
Posts: 461
Joined: Mon Nov 25, 2013 5:38 am
Location: Australia

Re: Application Menu

Post by coco2 »

Is there a way to change the application menu for example when a file requester is opened all the menu items in the application menu are greyed out including quit? This is how other applications do it like Firefox.
Post Reply