mirror of
https://github.com/ArthurSonzogni/FTXUI.git
synced 2025-09-28 16:29:34 +08:00
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:
@@ -305,6 +305,34 @@ TEST(ContainerTest, TakeFocus) {
|
||||
EXPECT_FALSE(c23->Active());
|
||||
}
|
||||
|
||||
TEST(ContainerTest, TabFocusable) {
|
||||
int selected = 0;
|
||||
auto c = Container::Tab(
|
||||
{
|
||||
Focusable(),
|
||||
NonFocusable(),
|
||||
Focusable(),
|
||||
NonFocusable(),
|
||||
},
|
||||
&selected);
|
||||
|
||||
selected = 0;
|
||||
EXPECT_TRUE(c->Focusable());
|
||||
EXPECT_TRUE(c->Focused());
|
||||
|
||||
selected = 1;
|
||||
EXPECT_FALSE(c->Focusable());
|
||||
EXPECT_FALSE(c->Focused());
|
||||
|
||||
selected = 2;
|
||||
EXPECT_TRUE(c->Focusable());
|
||||
EXPECT_TRUE(c->Focused());
|
||||
|
||||
selected = 3;
|
||||
EXPECT_FALSE(c->Focusable());
|
||||
EXPECT_FALSE(c->Focused());
|
||||
}
|
||||
|
||||
// Copyright 2020 Arthur Sonzogni. All rights reserved.
|
||||
// Use of this source code is governed by the MIT license that can be found in
|
||||
// the LICENSE file.
|
||||
|
Reference in New Issue
Block a user