Bluelikesky Posted September 29, 2023 Share Posted September 29, 2023 Hi. I have a problem with UI. I don't find a way to create a listbox with a vertical scrollbar.Items go outside the window. Once created the listbox: Unigine::WidgetWindowPtr selectionWindow = Unigine::WidgetWindow::create(gui, "Window", 0, 10); Unigine::WidgetListBoxPtr listbox = Unigine::WidgetListBox::create(gui); selectionWindow->addChild(listbox, Unigine::Gui::ALIGN_OVERLAP); How can i add a vertical scrollbar to have a usual c++ listbox ? Thanks in advance :-) Link to comment
karpych11 Posted October 2, 2023 Share Posted October 2, 2023 Hello. You can use the WidgetScrollBox for these purposes. Here's a small example: WidgetListBoxPtr list_box = WidgetListBox::create(); for (int i = 0; i < 30; i++) list_box->addItem(String::format("%d) item", i + 1)); WidgetScrollBoxPtr scroll_box = WidgetScrollBox::create(); scroll_box->addChild(list_box, Gui::ALIGN_LEFT); WidgetWindowPtr selection_window = WidgetWindow::create("Window", 0, 10); selection_window->setWidth(200); selection_window->setHeight(350); selection_window->setSizeable(true); selection_window->addChild(scroll_box, Gui::ALIGN_EXPAND); EngineWindowViewportPtr main_window = WindowManager::getMainWindow(); main_window->addChild(selection_window, Unigine::Gui::ALIGN_OVERLAP); And here is the result: Link to comment
Bluelikesky Posted October 6, 2023 Author Share Posted October 6, 2023 Wonderful. Thank you very much !!! :-) Link to comment
Recommended Posts