Hello, I encounter a problem when creating a ScrollView in the constructor of a window subclass.
My code works fine if I create the ScrollView elsewhere than in the constructor.
NodeWindow::NodeWindow(Context* context) : Window(context), node_(nullptr)
{
SetStyleAuto();
ScrollView* scroll = CreateChild<ScrollView>();
scroll->SetFixedSize(300, 100);
scroll->SetStyleAuto();
UIElement* sections = new UIElement(context_);
sections->SetFixedWidth(300);
sections->SetLayoutMode(LayoutMode::LM_VERTICAL);
sections->SetStyleAuto();
for (unsigned int i = 0; i < 10; i++)
{
ButtonText* btn = sections->CreateChild<ButtonText>("g");
btn->SetLabel("Button");
}
scroll->SetContentElement(sections);
}
With this version, the scrollview is empty.
When i move this code to a method called after construction, everything work fine.
nodeWindow_ = uiRoot_->CreateChild<NodeWindow>("NodeWindow");
nodeWindow_->Init();
This work, but it’s not a valid solution, so i need help thanks.