To initialize or configure a Combobox element, use the SComboboxData struct. This struct defines the items available in the list, the currently selected item index, a callback function for when the selection changes, and the element's size.
Key fields:
items: A std::vector<std::string> containing the list of options.currentItem: A size_t representing the index of the currently selected item.onChanged: A callback function std::function<void(CSharedPointer<CComboboxElement>, size_t)> that triggers when a user selects a new item. It provides a pointer to the combobox instance and the new index.size: A CDynamicSize object defining the element's dimensions.
SComboboxData data;
data.items = {"Option 1", "Option 2", "Option 3"};
data.currentItem = 0;
data.onChanged = [](Hyprutils::Memory::CSharedPointer<CComboboxElement> self, size_t newIndex) {
// Handle selection change
};
data.size = CDynamicSize{CDynamicSize::HT_SIZE_AUTO, CDynamicSize::HT_SIZE_AUTO, {}};