Creating a child with disabled parent doesn't visually disable the child (Issue #26408)

11 views
Skip to first unread message

Ryan Ogurek

unread,
Apr 25, 2026, 6:13:46 PM (3 days ago) Apr 25
to wx-...@googlegroups.com, Subscribed
ryancog created an issue (wxWidgets/wxWidgets#26408)

Description

Whenever a parent window is created, disabled, and then child windows are added, the child windows do not appear disabled.

The child windows are logically disabled. E.g. a button cannot be pressed.

I figure this is only an issue for platforms w/o wxHAS_NATIVE_ENABLED_MANAGEMENT. Afaics in wxWindowBase::CreateBase, SetParent() is called, which doesn't do the same enable updating (or child handling? I don't know enough here to understand if/why that's okay) that Reparent() does.

Expected vs observed behaviour:

Newly-created child windows should appear disabled.

Patch or snippet allowing to reproduce the problem:

// wxWidgets Disabled Parent

#include <wx/app.h>
#include <wx/frame.h>
#include <wx/panel.h>
#include <wx/sizer.h>
#include <wx/button.h>

class Frame : public wxFrame {
public:
    Frame();

private:
    void rebuild();

    wxPanel *mPanel;
    wxSizer *mInnerSizer;
};

class Sample : public wxApp {
public:
    bool OnInit() override {
        auto *frame{new Frame};
        frame->Show();
        return true;
    }
};

// NOLINTNEXTLINE(misc-use-internal-linkage)
wxIMPLEMENT_APP(Sample);

Frame::Frame() : wxFrame(nullptr, wxID_ANY, "Sample") {
    auto *panel{new wxPanel(this)};
    auto *sizer{new wxBoxSizer(wxVERTICAL)};

    mPanel = new wxPanel(panel);

    auto *button{new wxButton(panel, wxID_ANY, "Rebuild")};
    button->Bind(wxEVT_BUTTON, [this](wxCommandEvent&) { rebuild(); });
    sizer->Add(button, 0, wxEXPAND | wxALL, 10);

    mInnerSizer = new wxBoxSizer(wxVERTICAL);
    mPanel->SetSizer(mInnerSizer);

    sizer->Add(mPanel, 1, wxEXPAND | wxALL, 10);
    panel->SetSizer(sizer);

    rebuild();

    mPanel->Disable();
}

void Frame::rebuild() {
    mInnerSizer->Clear(true);

    mInnerSizer->Add(new wxButton(mPanel, wxID_ANY, "Button 2"), 0, wxEXPAND);

    Fit();
    SetMinSize(GetSize());

    mPanel->Layout();
}

To Reproduce:

Compiling and running the above sample, you can see that initially the "Button 2" is properly disabled, as mPanel->Disable() was called after the button was created (rebuild() is called immediately prior on first creation).

However, if you click "Rebuild", then the button no longer appears disabled.

Platform and version information

  • wxWidgets version you use: v3.3.2-70-ga6ce6599ec, probably an issue with at least 3.3.x in general
  • wxWidgets port you use: wxOSX
  • OS and its version: macOS 15


Reply to this email directly, view it on GitHub, or unsubscribe.
Triage notifications, keep track of coding agent tasks and review pull requests on the go with GitHub Mobile for iOS and Android. Download it today!
You are receiving this because you are subscribed to this thread.Message ID: <wxWidgets/wxWidgets/issues/26408@github.com>

Reply all
Reply to author
Forward
0 new messages