macOS Default Menu Handling

46 views
Skip to first unread message

Ryan Ogurek

unread,
May 31, 2026, 10:10:07 PM (6 days ago) May 31
to wx-users
Hello,

I've been looking at the way wxWidgets handles the macOS "default" items like "About" and "Preferences," and I'm a bit confused by it, stepping through the code with a debugger a bit.

I see CreateAppleMenu() and MacInstallMenuBar() in menu_osx.cpp, where in the former the About and preferences items are added unconditionally (if the static item ids are set) to a menu added to all menu bars (afaics).

CreateAppleMenu() creates "About %s" with the GetAppDisplayName() and "Preferences..." with the correct accelerator (although "Preferences..." is outdated, and macOS uses "Settings..." now, but that's an aside).

In MacInstallMenuBar() though, whenever these menu items are found, the item labels are replaced with the labels from the `wxItem`. This ends up replacing the labels created in `CreateAppleMenu()` (which were what I'd expect a macOS app to have, more or less).

For these menu items, I don't provide a label, so it just replaces it with the stock label and accelerator.

Is the intent that a non-stock item id should be set (in the macOS-specific static fields in wxApp, e.g. `s_macAboutMenuItemId`) for About in order to circumvent wxWidget's default handling, and instead the macOS specific default handling labels to persist?

If that's intentional, I suppose it is what it is, but it just seems rather awkward, so I thought I'd ask.

Thank you,
Ryan Ogurek

Ryan Ogurek

unread,
May 31, 2026, 10:17:50 PM (6 days ago) May 31
to wx-users
Oh, nevermind.

I'm not sure why I was thinking changing the `s_macAboutMenuItemId` would change anything...

Indeed, the label is replaced in any case, afaics, which seems to wholly defeat the (relevant bits of) logic in CreateAppleMenu().

So, what's going on here?

Lauri Nurmi

unread,
Jun 3, 2026, 8:04:48 AM (3 days ago) Jun 3
to wx-users
On Sun, 31 May 2026, Ryan Ogurek wrote:

> Oh, nevermind.
> I'm not sure why I was thinking changing the `s_macAboutMenuItemId` would change anything...
>
> Indeed, the label is replaced in any case, afaics, which seems to wholly defeat the (relevant bits of) logic in
> CreateAppleMenu().
>
> So, what's going on here?
>
> On Sunday, May 31, 2026 at 10:10:07 PM UTC-4 Ryan Ogurek wrote:
> Hello,
> I've been looking at the way wxWidgets handles the macOS "default" items like "About" and "Preferences,"
> and I'm a bit confused by it, stepping through the code with a debugger a bit.
>
> I see CreateAppleMenu() and MacInstallMenuBar() in menu_osx.cpp, where in the former the About and
> preferences items are added unconditionally (if the static item ids are set) to a menu added to all menu
> bars (afaics).

There's an open issue about this, with some analysis and discussion:
https://github.com/wxWidgets/wxWidgets/issues/16888

Kafrene Trading

unread,
Jun 3, 2026, 10:47:28 PM (3 days ago) Jun 3
to wx-u...@googlegroups.com
I see, thank you for the reference.

Ryan Ogurek

> On Jun 3, 2026, at 08:04, Lauri Nurmi <lan...@iki.fi> wrote:
> --
> Please read https://www.wxwidgets.org/support/mlhowto.htm before posting.
> --- You received this message because you are subscribed to a topic in the Google Groups "wx-users" group.
> To unsubscribe from this topic, visit https://groups.google.com/d/topic/wx-users/9_ZcZTkrbqo/unsubscribe.
> To unsubscribe from this group and all its topics, send an email to wx-users+u...@googlegroups.com.
> To view this discussion visit https://groups.google.com/d/msgid/wx-users/b25464d6-4d6a-985d-27cc-4eead19fe4a2%40iki.fi.
Reply all
Reply to author
Forward
0 new messages