wxDarkModeSettings::GetMenuColour not called MSW, Dark mode. (Issue #26334)

25 views
Skip to first unread message

Dan

unread,
Mar 31, 2026, 7:12:45 PM (3 days ago) Mar 31
to wx-...@googlegroups.com, Subscribed
CEXT-Dan created an issue (wxWidgets/wxWidgets#26334)

3.3.2 with wxPython 4.3.0a16047

I noticed this while browsing around, however, I noticed that it’s never called with a PopupMenu. Should it be?
Not a big deal if that's not the intent. Just exploring

#if wxCHECK_VERSION(3, 3, 0)
#include <wx/msw/darkmode.h>
class PyRxDarkModeSettings : public wxDarkModeSettings
{
public:

    static COLORREF getPaletteBackground()
    {
#ifndef _ARXTARGET
        return RGB(49, 56, 66);
#else
        auto mgr = CAdUiThemeManager{};
        auto theme = mgr.GetTheme(PALETTE_SET_THEME);
        if (theme == nullptr)
            return RGB(49, 56, 66);
        COLORREF clr = theme->GetColor(kPaletteBackground);
        mgr.ReleaseTheme(theme);
        return clr;
#endif
    }

    wxColour GetMenuColour(wxMenuColour which) override
    {
        static COLORREF clr = getPaletteBackground();
        switch (which)
        {
            case wxMenuColour::StandardBg:
                return wxColour(clr);
            default:
                return wxDarkModeSettings::GetMenuColour(which);
        }
    }

    wxColour GetColour(wxSystemColour index) override
    {
        static COLORREF clr = getPaletteBackground();
        switch (index)
        {
            case wxSYS_COLOUR_ACTIVECAPTION:
            case wxSYS_COLOUR_APPWORKSPACE:
            case wxSYS_COLOUR_INFOBK:
            case wxSYS_COLOUR_LISTBOX:
            case wxSYS_COLOUR_WINDOW:
            case wxSYS_COLOUR_BTNFACE:
                return wxColour(clr);

            default:
                return wxDarkModeSettings::GetColour(index);
        }
    }
};
#endif //wxVERSION_NUMBER
class MyPopupMenu(wx.Menu):
    def __init__(self):
        wx.Menu.__init__(self)
        item = wx.MenuItem(self, wx.NewId(), "Item One")
        self.Append(item)
        self.Bind(wx.EVT_MENU, self.OnItem1, item)
        item = wx.MenuItem(self, wx.NewId(), "Item Two")
        self.Append(item)
        self.Bind(wx.EVT_MENU, self.OnItem2, item)
        item = wx.MenuItem(self, wx.NewId(), "Item Three")
        self.Append(item)
        self.Bind(wx.EVT_MENU, self.OnItem3, item)

    def OnItem1(self, event):
        print("OnItem1")

    def OnItem2(self, event):
        print("OnItem2")

    def OnItem3(self, event):
        print("OnItem3")


class MyPanel(wx.Panel):
    def __init__(self):
        super().__init__()
        self.Bind(wx.EVT_SHOW, self.OnShow)

    def OnShow(self, event):
        # import the XRC
        _res = Ap.ResourceOverride()
        self.res = xrc.XmlResource("./wxPaletteTab.xrc")
        self.childpanel = self.res.LoadPanel(self, "ID_WXPALETTETAB")
        if not self.childpanel:
            raise Exception("failed to find xrc file")

        # create a sizer and add the child
        sizer = wx.BoxSizer(wx.VERTICAL)
        sizer.Add(self.childpanel, 1, wx.ALL | wx.EXPAND)
        self.SetSizerAndFit(sizer)
        self.Layout()

        self.index = 0
        self.OnInitListCtrl()

        # bind events
        self.Bind(wx.EVT_CONTEXT_MENU, self.OnContextMenu, self.listctrl)

    def OnContextMenu(self, event):
        self.PopupMenu(MyPopupMenu(), self.ScreenToClient(event.GetPosition()))
wx2.png (view on web)


Reply to this email directly, view it on GitHub, or unsubscribe.
You are receiving this because you are subscribed to this thread.Message ID: <wxWidgets/wxWidgets/issues/26334@github.com>

Dan

unread,
Mar 31, 2026, 7:50:23 PM (3 days ago) Mar 31
to wx-...@googlegroups.com, Subscribed
CEXT-Dan left a comment (wxWidgets/wxWidgets#26334)

wxSYS_COLOUR_BTNFACE is hit in the debugger, but the color is the same as default


Reply to this email directly, view it on GitHub, or unsubscribe.

You are receiving this because you are subscribed to this thread.Message ID: <wxWidgets/wxWidgets/issues/26334/4166420558@github.com>

PB

unread,
Apr 1, 2026, 6:37:00 AM (3 days ago) Apr 1
to wx-...@googlegroups.com, Subscribed
PBfordev left a comment (wxWidgets/wxWidgets#26334)

I think there may be a difference. In dark mode, we draw menus in the menu bar by ourselves when handling an undocumented WM_MENUBAR_DRAWMENUITEM:
https://github.com/wxWidgets/wxWidgets/blob/c456ccb28f96f536774896b312aca1aa9ebb5b0a/src/msw/darkmode.cpp#L722-L725

But we let the theme draw the menu item in wxMenuItem::OnDrawItem():
https://github.com/wxWidgets/wxWidgets/blob/c456ccb28f96f536774896b312aca1aa9ebb5b0a/src/msw/menuitem.cpp#L1000-L1003
i.e., wxDarkModeSettings::GetMenuColour() does not seem to be called there.


Reply to this email directly, view it on GitHub, or unsubscribe.

You are receiving this because you are subscribed to this thread.Message ID: <wxWidgets/wxWidgets/issues/26334/4169136995@github.com>

Dan

unread,
Apr 1, 2026, 8:09:23 AM (3 days ago) Apr 1
to wx-...@googlegroups.com, Subscribed
CEXT-Dan left a comment (wxWidgets/wxWidgets#26334)

Thanks for the reply, I don’t need the behavior changed. Just testing how close I can align with AutoCAD’s theme. Dark mode looks amazing!


Reply to this email directly, view it on GitHub, or unsubscribe.

You are receiving this because you are subscribed to this thread.Message ID: <wxWidgets/wxWidgets/issues/26334/4169629505@github.com>

Dan

unread,
Apr 1, 2026, 8:09:23 AM (3 days ago) Apr 1
to wx-...@googlegroups.com, Subscribed

Closed #26334 as completed.


Reply to this email directly, view it on GitHub, or unsubscribe.

You are receiving this because you are subscribed to this thread.Message ID: <wxWidgets/wxWidgets/issue/26334/issue_event/24109747592@github.com>

PB

unread,
Apr 1, 2026, 8:44:22 AM (2 days ago) Apr 1
to wx-...@googlegroups.com, Subscribed
PBfordev left a comment (wxWidgets/wxWidgets#26334)

Well, I would still consider it a bug. Not sure how difficult it would be to fix.


Reply to this email directly, view it on GitHub, or unsubscribe.

You are receiving this because you are subscribed to this thread.Message ID: <wxWidgets/wxWidgets/issues/26334/4169839369@github.com>

Reply all
Reply to author
Forward
0 new messages