Skip to main content

Combobox

#include "toolkit/combobox.hpp"

A dropdown selection widget over a fixed list of strings. Inherits Widget.

The input for the values in a std::vector<std::string>>.

Combobox screenshot

Example​

auto combo = std::make_unique<toolkit::Combobox>(
std::vector<std::string>{"Small", "Medium", "Large"});
combo->set_selected(1);
combo->on_change = [](int index) { /* ... */ };

Construction​

explicit Combobox(std::vector<std::string> items = {});

API​

MemberDescription
set_items(std::vector<std::string>)Replace the item list
set_selected(int index) / selected()Selected item index (-1 if none)
selected_text()Text of the currently selected item

Callbacks​

CallbackDescription
on_change — std::function<void(int)>Fired with the new index when the selection changes