Page 1 of 1

Application Menu

Posted: Mon May 20, 2024 6:44 am
by coco2
About and settings menus seem to be greyed out, does anyone know how to enable them?

Re: Application Menu

Posted: Mon May 20, 2024 9:04 am
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

Re: Application Menu

Posted: Mon May 20, 2024 10:37 pm
by coco2
Thanks I got it working

Re: Application Menu

Posted: Tue May 21, 2024 10:30 am
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?

Re: Application Menu

Posted: Tue May 21, 2024 11:18 am
by Mindphazer
Can you post your code ?

Re: Application Menu

Posted: Tue May 21, 2024 11:25 am
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.

Re: Application Menu

Posted: Tue May 21, 2024 11:31 am
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.