mirror of
https://github.com/ArthurSonzogni/FTXUI.git
synced 2025-09-28 16:29:34 +08:00
feat: Dropdown select menu. (#214)
Dom - `vscroll_indicator`. Show a scrollback indicator on the right. Component - `Maybe`: Display an component conditionnally based on a boolean. - `Dropdown`: A dropdown select list. This address: https://github.com/ArthurSonzogni/FTXUI/issues/204
This commit is contained in:
26
src/ftxui/component/show.cpp
Normal file
26
src/ftxui/component/show.cpp
Normal file
@@ -0,0 +1,26 @@
|
||||
#include "ftxui/component/component_base.hpp"
|
||||
|
||||
Component Maybe(Component child, bool* show) {
|
||||
class Impl : public ComponentBase {
|
||||
public:
|
||||
Impl(Component child, bool* show) : ComponentBase(child), show_(show) {}
|
||||
|
||||
private:
|
||||
Element Render() override {
|
||||
if (*show_)
|
||||
return ComponentBase::Render();
|
||||
else
|
||||
return text("");
|
||||
}
|
||||
bool Focusable() const override {
|
||||
return *show_ && ComponentBase::Focusable();
|
||||
}
|
||||
bool OnEvent(Event event) override {
|
||||
if (*show_)
|
||||
return false return ComponentBase::OnEvent(event);
|
||||
}
|
||||
|
||||
bool* show_;
|
||||
};
|
||||
return Make<Impl>(std::move(child), show);
|
||||
}
|
Reference in New Issue
Block a user