MacOS Application Menu

Just starting out? Need help? Post your questions and find answers here.
User avatar
tikidays
User
User
Posts: 46
Joined: Tue Oct 24, 2023 6:47 am
Location: New Zealand
Contact:

MacOS Application Menu

Post by tikidays »

Hi,

is anyone able to point me how I change the Application name, and access the About and Settings menus on MacOS?

- The Application menu is called "PureBasic.0"
- "About PureBasic.0" is disabled, as is "Settings."

Can't find anything with an example, and the manual doesn't appear to reference this apart from the constants.

Thanks in advance!
wombats
Enthusiast
Enthusiast
Posts: 720
Joined: Thu Dec 29, 2011 5:03 pm

Re: MacOS Application Menu

Post by wombats »

Use the constants as the MenuItemID:

Code: Select all

Global quit

Procedure OnPreferencesClicked()
  MessageRequester("Preferences", "Preferences...")
EndProcedure

Procedure OnAboutClicked()
  MessageRequester("About", "My Application")
EndProcedure

Procedure OnQuitClicked()
  If MessageRequester("Quit", "Do you want to quit?", #PB_MessageRequester_YesNo) = #PB_MessageRequester_Yes
    quit = #True
  EndIf
EndProcedure

Procedure OnWindowClosed()
  quit = #True
EndProcedure

OpenWindow(0, 0, 0, 320, 240, "My Application", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)

CreateMenu(0, WindowID(0))

MenuItem(#PB_Menu_Preferences, "")
MenuItem(#PB_Menu_About, "")
MenuItem(#PB_Menu_Quit, "")

BindMenuEvent(0, #PB_Menu_Preferences, @OnPreferencesClicked())
BindMenuEvent(0, #PB_Menu_About, @OnAboutClicked())
BindMenuEvent(0, #PB_Menu_Quit, @OnQuitClicked())

BindEvent(#PB_Event_CloseWindow, @OnWindowClosed())

Repeat : WaitWindowEvent() : Until quit
PureBasic.0 will change when you build your program as an executable. It uses the name you use for the executable.
User avatar
tikidays
User
User
Posts: 46
Joined: Tue Oct 24, 2023 6:47 am
Location: New Zealand
Contact:

Re: MacOS Application Menu

Post by tikidays »

Thank you so much! I only need to add the create menu part, thought this was odd as they ware already there.
Post Reply