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.
Newly-created child windows should appear disabled.
// 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();
}
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.
—
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.![]()