Handling the menu when opening child windows
Posted: Thu May 23, 2024 12:29 am
Since learning that hiding a menu is not really something you need to do on a Mac I started figuring out what is supposed to happen when you open a child window. The menu on the parent should be freed and a new menu should be opened. However I've come across something odd when doing this the application menu seems to change to the name of the first menu on the parent window (File). Does anyone know how to get this to work, so than when you go to File > Open, the menu disappears leaving just the application menu?
Code: Select all
Enumeration
#MenuOpen
#MenuQuit
EndEnumeration
Procedure ShowMainMenu()
CreateMenu(0, WindowID(0))
MenuTitle("File")
MenuItem(#MenuOpen, "Open...")
MenuItem(#MenuQuit, "Quit")
MenuItem(#PB_Menu_About, "About")
MenuItem(#PB_Menu_Preferences, "Preferences")
MenuItem(#PB_Menu_Quit, "Quit")
EndProcedure
Define quit.i = 0
OpenWindow(0, 0, 0, 400, 300, "Test macOS Menu", #PB_Window_SystemMenu | #PB_Window_MinimizeGadget | #PB_Window_MaximizeGadget | #PB_Window_ScreenCentered)
ShowMenu()
Define event.i
Repeat
event = WaitWindowEvent(10)
Select event
Case #PB_Event_Menu
Select EventMenu()
Case #MenuOpen
FreeMenu(0)
OpenFileRequester("Open", "", "All files (*.*)|*.*", 0)
ShowMainMenu()
Case #MenuQuit
quit = 1
EndSelect
EndSelect
Until event = #PB_Event_CloseWindow Or quit