ADropdownList#
A button with dropdown list.

| Header: | #include <AUI/View/ADropdownList.h> |
| CMake: | aui_link(my_target PUBLIC aui::views) |
Detailed Description#
Shows the selected item as a button; a click opens a popup with all the items. The items come from a list model of
strings (AListModel<AString> is the simplest one).
|
selectionId() is a property with the index of the selected item (starting from 0, the first item is selected by
default). Bind it or listen to selectionChanged:
auto list = _new<ADropdownList>(AListModel<AString>::make({ "one-way flight", "return flight" }));
AObject::connect(list->selectionId().changed, AObject::GENERIC_OBSERVER, [](int index) {
ALogger::info("App") << "Selected " << index;
});
The model can be replaced later with setModel. Like any other view, the list can be disabled with setDisabled().
Examples#
examples/7guis/flight_booker/src/main.cpp
7GUIs Flight Booker — Flight Booker.
// Set contents
window->setContents(Centered {
Vertical {
_new<ADropdownList>(AListModel<AString>::make({ "one-way flight", "return flight" })) AUI_LET {
AObject::connect(AUI_REACT(state->isReturnFlight ? 1 : 0), it->selectionId());
AObject::connect(it->selectionId().changed, AObject::GENERIC_OBSERVER, [=](int newSelection) {
state->isReturnFlight = newSelection == 1;
});
},
examples/ui/views/src/ExampleWindow.cpp
Views Example — All-in-one views building example.
Public Methods#
selectionId#
Selected id property.
Examples: