mirror of
https://github.com/MihailRis/voxelcore.git
synced 2026-10-04 18:41:51 +00:00
add onmouseover, onmouseout ui events & cleanup
This commit is contained in:
parent
418a400ea3
commit
05d6fbd995
5 changed files with 32 additions and 53 deletions
|
|
@ -19,14 +19,14 @@ SelectBox::SelectBox(
|
|||
: Button(gui, selected.text, padding, nullptr, glm::vec2(contentWidth, -1)),
|
||||
options(std::move(options)) {
|
||||
|
||||
listenClick([this](GUI& gui) {
|
||||
listenAction(UIAction::CLICK, [this](GUI& gui) {
|
||||
auto panel = std::make_shared<Panel>(gui, getSize());
|
||||
panel->setPos(calcPos() + glm::vec2(0, size.y));
|
||||
for (const auto& option : this->options) {
|
||||
auto button = std::make_shared<Button>(
|
||||
gui, option.text, glm::vec4(10.0f), nullptr, glm::vec2(-1.0f)
|
||||
);
|
||||
button->listenFocus([this, option](GUI& gui) {
|
||||
button->listenAction(UIAction::FOCUS, [this, option](GUI& gui) {
|
||||
setSelected(option);
|
||||
changeCallbacks.notify(gui, option.value);
|
||||
});
|
||||
|
|
@ -34,7 +34,7 @@ SelectBox::SelectBox(
|
|||
}
|
||||
panel->setZIndex(GUI::CONTEXT_MENU_ZINDEX);
|
||||
gui.setFocus(panel);
|
||||
panel->listenDefocus([panel=panel.get()](GUI& gui) {
|
||||
panel->listenAction(UIAction::DEFOCUS, [panel=panel.get()](GUI& gui) {
|
||||
gui.remove(panel);
|
||||
});
|
||||
gui.add(panel);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue