Archive 17/01/2023.

DropDownList. Empty popup menu

itisscan

I want to create DropDownList in the following way, but I have some problems.

  1. First, I define Urho3D::Window* object and define DefaultStyle.xml, which is used default by Urho3D.
        // Load XML file containing default UI style sheet
        XMLFile* style = m_pConstantResourceCache->GetResource<XMLFile>("UI/DefaultStyle.xml");
        GetSubsystem<UI>()->GetRoot()->SetDefaultStyle(style);

        // Create the Window and add it to the UI's root node
        m_pLevelManagerWindow = new Window(context_);
        GetSubsystem<UI>()->GetRoot()->AddChild(m_pLevelManagerWindow);
        
        // Set Window size and layout settings
        m_pLevelManagerWindow->SetMinSize(684, 692);
        m_pLevelManagerWindow->SetLayout(LM_VERTICAL, 6, IntRect(6, 6, 6, 6));
        m_pLevelManagerWindow->SetAlignment(HA_CENTER, VA_CENTER);
        m_pLevelManagerWindow->SetName("Window");
        m_pLevelManagerWindow->SetHeight(600);[/code]
2)Next, I create Urho3D::DropDownList* and attach it to the window.
	[code]
        DropDownList* list = new DropDownList(context_);
        unsigned selection = M_MAX_UNSIGNED;
        list->SetSelection(selection);
        list->SetMinHeight(40);
        list->SetStyleAuto();
        m_pLevelManagerWindow->AddChild(list);

3)Finally, create Text* object and add it to the list.
Text* levelName = new Text(context_); levelName->SetText("Level 1"); levelName->SetStyleAuto(); list->AddItem(levelName);

In the result, I have button in order to select item from dropdownlist. BUT, when I click on this button popup menu is empty. Actually, it is looked like small square. I have uploaded image where yo can see it.

How I can fix it ?

Sasha7b9o

[code]DropDownList* list = new DropDownList(context_);
unsigned selection = M_MAX_UNSIGNED;
list->SetSelection(selection);
list->SetFixedSize(300, 20); << NEW!!!
list->SetStyleAuto();
gUIRoot->AddChild(list);

Text* levelName = new Text(context_);
levelName->SetText("Level 1");
levelName->SetStyleAuto();
levelName->SetFixedSize(300, 20);           << NEW!!!
list->AddItem(levelName);[/code]

?an be, so?

itisscan

[quote=“Sasha7b9o”][code]DropDownList* list = new DropDownList(context_);
unsigned selection = M_MAX_UNSIGNED;
list->SetSelection(selection);
list->SetFixedSize(300, 20); << NEW!!!
list->SetStyleAuto();
gUIRoot->AddChild(list);

Text* levelName = new Text(context_);
levelName->SetText("Level 1");
levelName->SetStyleAuto();
levelName->SetFixedSize(300, 20);           << NEW!!!
list->AddItem(levelName);[/code]

?an be, so?[/quote]

It does help only to make popup menu bigger, but I can’t see items. You can see result here.

Sasha7b9o

DropDownList* list = new DropDownList(context_); unsigned selection = M_MAX_UNSIGNED; list->SetSelection(selection); list->SetFixedSize(300, 20); << NEW!!!! list->SetStyleAuto(); gUIRoot->AddChild(list); !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! gUIRoot - GetSubsystem<UI>()->GetRoot()

Sasha7b9o

[spoiler][code] Window *wnd = new Window(context_);
GetSubsystem()->GetRoot()->AddChild(wnd);

// Set Window size and layout settings
wnd->SetMinSize(684, 692);
wnd->SetLayout(LM_VERTICAL, 6, IntRect(6, 6, 6, 6));
wnd->SetAlignment(HA_CENTER, VA_CENTER);
wnd->SetName("Window");
wnd->SetHeight(600);

DropDownList* list = new DropDownList(context_);
unsigned selection = M_MAX_UNSIGNED;
list->SetSelection(selection);
list->SetFixedSize(300, 20);
list->SetStyleAuto();
wnd->AddChild(list);

Text* levelName = new Text(context_);
levelName->SetText("Level 1");
levelName->SetStyleAuto();
levelName->SetFixedSize(300, 20);
list->AddItem(levelName);[/code]

[/spoiler]

itisscan

Problem was solved. Thanks. :wink: However, I do not why I couldn’t see items. I suppose that there can be something messed up with style defining.