mirror of
https://github.com/ArthurSonzogni/FTXUI.git
synced 2024-11-22 10:40:00 +08:00
Dropdown now closes when using return key to select (#731)
Co-authored-by: ArthurSonzogni <sonzogniarthur@gmail.com>
This commit is contained in:
parent
eb9a701fd7
commit
20baaef5b8
@ -58,6 +58,24 @@ Component Dropdown(ConstStringListRef entries, int* selected) {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Switch focus in between the checkbox and the radiobox when selecting it.
|
||||||
|
bool OnEvent(ftxui::Event event) override {
|
||||||
|
const bool show_old = show_;
|
||||||
|
const int selected_old = *selected_;
|
||||||
|
const bool handled = ComponentBase::OnEvent(event);
|
||||||
|
|
||||||
|
if (!show_old && show_) {
|
||||||
|
radiobox_->TakeFocus();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (selected_old != *selected_) {
|
||||||
|
checkbox_->TakeFocus();
|
||||||
|
show_ = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return handled;
|
||||||
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
ConstStringListRef entries_;
|
ConstStringListRef entries_;
|
||||||
bool show_ = false;
|
bool show_ = false;
|
||||||
|
Loading…
Reference in New Issue
Block a user