Improve ComponentBase and Container::Tab Focusable implementations (#341)

- Provide better defaults for ComponentBase `Focusable()` and
  `ActiveChild()` methods. This resolves:
  https://github.com/ArthurSonzogni/FTXUI/issues/335

- Implement `Container::Tab` 's  `Focusable()` methods. This prevents
  the users to navigate into a tab with no interactivity.
This commit is contained in:
Arthur Sonzogni
2022-02-19 11:49:12 +01:00
committed by GitHub
parent f95ed885bb
commit 20f16b3984
5 changed files with 62 additions and 3 deletions

View File

@@ -190,6 +190,12 @@ class TabContainer : public ContainerBase {
return text("Empty container");
}
bool Focusable() const override {
if (children_.size() == 0)
return false;
return children_[*selector_ % children_.size()]->Focusable();
}
bool OnMouseEvent(Event event) override {
return ActiveChild()->OnEvent(event);
}