add 'onselect' callback & remove 'default' tag

This commit is contained in:
MihailRis
2025-06-28 02:46:54 +03:00
parent 47f7259c72
commit f17167f8c9
6 changed files with 60 additions and 19 deletions
+6 -1
View File
@@ -26,8 +26,9 @@ SelectBox::SelectBox(
auto button = std::make_shared<Button>(
gui, option.text, glm::vec4(10.0f), nullptr, glm::vec2(-1.0f)
);
button->listenFocus([this, option](GUI&) {
button->listenFocus([this, option](GUI& gui) {
setSelected(option);
changeCallbacks.notify(gui, option.value);
});
panel->add(button);
}
@@ -40,6 +41,10 @@ SelectBox::SelectBox(
});
}
void SelectBox::listenChange(onstringchange&& callback) {
changeCallbacks.listen(std::move(callback));
}
void SelectBox::setSelected(const Option& selected) {
this->selected = selected;
this->label->setText(selected.text);