mirror of
https://github.com/ArthurSonzogni/FTXUI.git
synced 2024-11-22 10:40:00 +08:00
Fix ResizableSplit handling keyboard navigation incorrectly (#842)
Co-authored-by: ArthurSonzogni <sonzogniarthur@gmail.com>
This commit is contained in:
parent
e03a0797be
commit
0dfd59bd09
@ -25,6 +25,7 @@ current (development)
|
|||||||
Fixed by @chrysante in chrysante in PR #776.
|
Fixed by @chrysante in chrysante in PR #776.
|
||||||
- Bugfix: Propertly restore cursor shape on exit. See #792.
|
- Bugfix: Propertly restore cursor shape on exit. See #792.
|
||||||
- Bugfix: Fix cursor position in when in the last column. See #831.
|
- Bugfix: Fix cursor position in when in the last column. See #831.
|
||||||
|
- Bugfix: Fix `ResizeableSplit` keyboard navigation. Fixed by #842.
|
||||||
|
|
||||||
### Dom
|
### Dom
|
||||||
- Feature: Add `hscroll_indicator`. It display an horizontal indicator
|
- Feature: Add `hscroll_indicator`. It display an horizontal indicator
|
||||||
|
@ -23,10 +23,32 @@ class ResizableSplitBase : public ComponentBase {
|
|||||||
public:
|
public:
|
||||||
explicit ResizableSplitBase(ResizableSplitOption options)
|
explicit ResizableSplitBase(ResizableSplitOption options)
|
||||||
: options_(std::move(options)) {
|
: options_(std::move(options)) {
|
||||||
Add(Container::Horizontal({
|
switch (options_->direction()) {
|
||||||
options_->main,
|
case Direction::Left:
|
||||||
options_->back,
|
Add(Container::Horizontal({
|
||||||
}));
|
options_->main,
|
||||||
|
options_->back,
|
||||||
|
}));
|
||||||
|
break;
|
||||||
|
case Direction::Right:
|
||||||
|
Add(Container::Horizontal({
|
||||||
|
options_->back,
|
||||||
|
options_->main,
|
||||||
|
}));
|
||||||
|
break;
|
||||||
|
case Direction::Up:
|
||||||
|
Add(Container::Vertical({
|
||||||
|
options_->main,
|
||||||
|
options_->back,
|
||||||
|
}));
|
||||||
|
break;
|
||||||
|
case Direction::Down:
|
||||||
|
Add(Container::Vertical({
|
||||||
|
options_->back,
|
||||||
|
options_->main,
|
||||||
|
}));
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool OnEvent(Event event) final {
|
bool OnEvent(Event event) final {
|
||||||
|
@ -19,7 +19,7 @@ namespace ftxui {
|
|||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
Component BasicComponent() {
|
Component BasicComponent() {
|
||||||
return Renderer([] { return text(""); });
|
return Renderer([](bool focused) { return text(""); });
|
||||||
}
|
}
|
||||||
|
|
||||||
Event MousePressed(int x, int y) {
|
Event MousePressed(int x, int y) {
|
||||||
@ -207,5 +207,32 @@ TEST(ResizableSplit, BasicBottomWithCustomSeparator) {
|
|||||||
EXPECT_EQ(position, 2);
|
EXPECT_EQ(position, 2);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
TEST(ResizableSplit, NavigationVertical) {
|
||||||
|
int position = 0;
|
||||||
|
auto component_top = BasicComponent();
|
||||||
|
auto component_bottom = BasicComponent();
|
||||||
|
auto component =
|
||||||
|
ResizableSplitTop(component_top, component_bottom, &position);
|
||||||
|
|
||||||
|
EXPECT_TRUE(component_top->Active());
|
||||||
|
EXPECT_FALSE(component_bottom->Active());
|
||||||
|
|
||||||
|
EXPECT_FALSE(component->OnEvent(Event::ArrowRight));
|
||||||
|
EXPECT_TRUE(component_top->Active());
|
||||||
|
EXPECT_FALSE(component_bottom->Active());
|
||||||
|
|
||||||
|
EXPECT_TRUE(component->OnEvent(Event::ArrowDown));
|
||||||
|
EXPECT_FALSE(component_top->Active());
|
||||||
|
EXPECT_TRUE(component_bottom->Active());
|
||||||
|
|
||||||
|
EXPECT_FALSE(component->OnEvent(Event::ArrowDown));
|
||||||
|
EXPECT_FALSE(component_top->Active());
|
||||||
|
EXPECT_TRUE(component_bottom->Active());
|
||||||
|
|
||||||
|
EXPECT_TRUE(component->OnEvent(Event::ArrowUp));
|
||||||
|
EXPECT_TRUE(component_top->Active());
|
||||||
|
EXPECT_FALSE(component_bottom->Active());
|
||||||
|
}
|
||||||
|
|
||||||
} // namespace ftxui
|
} // namespace ftxui
|
||||||
// NOLINTEND
|
// NOLINTEND
|
||||||
|
Loading…
Reference in New Issue
Block a user