mirror of
https://github.com/MihailRis/voxelcore.git
synced 2026-10-05 02:51:49 +00:00
add 'onselect' callback & remove 'default' tag
This commit is contained in:
parent
47f7259c72
commit
f17167f8c9
6 changed files with 60 additions and 19 deletions
|
|
@ -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);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue