From dda289670034603f2bac10d42a4f657f5db27a2a Mon Sep 17 00:00:00 2001 From: James Parker Date: Thu, 14 Mar 2024 11:29:34 +0000 Subject: [PATCH 1/8] Feature: Dropdown options with callback --- examples/component/dropdown.cpp | 6 ++-- include/ftxui/component/component.hpp | 2 +- include/ftxui/component/component_options.hpp | 11 ++++++ src/ftxui/component/dropdown.cpp | 36 ++++++++++++++----- 4 files changed, 43 insertions(+), 12 deletions(-) diff --git a/examples/component/dropdown.cpp b/examples/component/dropdown.cpp index 04febeb82..13fbe1d63 100644 --- a/examples/component/dropdown.cpp +++ b/examples/component/dropdown.cpp @@ -30,12 +30,12 @@ int main() { auto layout = Container::Vertical({ Container::Horizontal({ - Dropdown(&entries, &selected_1), + Dropdown(&entries, &selected_1, { .on_change = [&] { selected_3 = selected_1; } } ), // Keep in sync with selected_3. Dropdown(&entries, &selected_2), }), Container::Horizontal({ - Dropdown(&entries, &selected_3), - Dropdown(&entries, &selected_4), + Dropdown(&entries, &selected_3, { .border = false }), + Dropdown(&entries, &selected_4, { .border = false }), }), }); diff --git a/include/ftxui/component/component.hpp b/include/ftxui/component/component.hpp index 984760307..20d039f18 100644 --- a/include/ftxui/component/component.hpp +++ b/include/ftxui/component/component.hpp @@ -74,7 +74,7 @@ Component Radiobox(ConstStringListRef entries, int* selected_, RadioboxOption options = {}); -Component Dropdown(ConstStringListRef entries, int* selected); +Component Dropdown(ConstStringListRef entries, int* selected, DropdownOption options = {}); Component Toggle(ConstStringListRef entries, int* selected); // General slider constructor: diff --git a/include/ftxui/component/component_options.hpp b/include/ftxui/component/component_options.hpp index 54249f5de..80480c423 100644 --- a/include/ftxui/component/component_options.hpp +++ b/include/ftxui/component/component_options.hpp @@ -148,6 +148,17 @@ struct CheckboxOption { std::function on_change = [] {}; }; +/// @brief Option for the Dropdown component. +/// @ingroup component +struct DropdownOption { + + bool border = true; + + // Observer: + /// Called when the user change the state. + std::function on_change = [] {}; +}; + /// @brief Used to define style for the Input component. struct InputState { Element element; diff --git a/src/ftxui/component/dropdown.cpp b/src/ftxui/component/dropdown.cpp index a90686e5f..7602334b6 100644 --- a/src/ftxui/component/dropdown.cpp +++ b/src/ftxui/component/dropdown.cpp @@ -19,10 +19,10 @@ namespace ftxui { /// @ingroup component /// @param entries The list of entries to display. /// @param selected The index of the selected entry. -Component Dropdown(ConstStringListRef entries, int* selected) { +Component Dropdown(ConstStringListRef entries, int* selected, DropdownOption option) { class Impl : public ComponentBase { public: - Impl(ConstStringListRef entries, int* selected) + Impl(ConstStringListRef entries, int* selected, DropdownOption dropDownOption) : entries_(entries), selected_(selected) { CheckboxOption option; option.transform = [](const EntryState& s) { @@ -37,12 +37,18 @@ Component Dropdown(ConstStringListRef entries, int* selected) { return hbox({prefix, t}); }; checkbox_ = Checkbox(&title_, &show_, option); - radiobox_ = Radiobox(entries_, selected_); + + RadioboxOption radioboxOption; + radioboxOption.on_change = dropDownOption.on_change; + + radiobox_ = Radiobox(entries_, selected_, radioboxOption); Add(Container::Vertical({ checkbox_, Maybe(radiobox_, &show_), })); + + border_ = dropDownOption.border; } Element Render() override { @@ -50,17 +56,30 @@ Component Dropdown(ConstStringListRef entries, int* selected) { title_ = entries_[static_cast(*selected_)]; if (show_) { const int max_height = 12; - return vbox({ + auto element = vbox({ checkbox_->Render(), separator(), radiobox_->Render() | vscroll_indicator | frame | size(HEIGHT, LESS_THAN, max_height), - }) | - border; + }); + + if (border_) + { + element |= border; + } + + return element; + } + + auto element = checkbox_->Render(); + + if (border_) + { + element |= border; } return vbox({ - checkbox_->Render() | border, + element, filler(), }); } @@ -86,13 +105,14 @@ Component Dropdown(ConstStringListRef entries, int* selected) { private: ConstStringListRef entries_; bool show_ = false; + bool border_ = true; int* selected_; std::string title_; Component checkbox_; Component radiobox_; }; - return Make(entries, selected); + return Make(entries, selected, option); } } // namespace ftxui From 4b0d687c5fb748145ab21658d80187cdc578ec53 Mon Sep 17 00:00:00 2001 From: James Parker Date: Sat, 16 Mar 2024 09:03:33 +0000 Subject: [PATCH 2/8] Revert example dropdown --- examples/component/dropdown.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/examples/component/dropdown.cpp b/examples/component/dropdown.cpp index 13fbe1d63..04febeb82 100644 --- a/examples/component/dropdown.cpp +++ b/examples/component/dropdown.cpp @@ -30,12 +30,12 @@ int main() { auto layout = Container::Vertical({ Container::Horizontal({ - Dropdown(&entries, &selected_1, { .on_change = [&] { selected_3 = selected_1; } } ), // Keep in sync with selected_3. + Dropdown(&entries, &selected_1), Dropdown(&entries, &selected_2), }), Container::Horizontal({ - Dropdown(&entries, &selected_3, { .border = false }), - Dropdown(&entries, &selected_4, { .border = false }), + Dropdown(&entries, &selected_3), + Dropdown(&entries, &selected_4), }), }); From 00fbdd98d4c302778f081970d67d89d83c73da5b Mon Sep 17 00:00:00 2001 From: James Parker Date: Sat, 16 Mar 2024 09:09:37 +0000 Subject: [PATCH 3/8] clang-format --- include/ftxui/component/component.hpp | 5 ++++- include/ftxui/component/component_options.hpp | 1 - 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/include/ftxui/component/component.hpp b/include/ftxui/component/component.hpp index 20d039f18..fd4aec02b 100644 --- a/include/ftxui/component/component.hpp +++ b/include/ftxui/component/component.hpp @@ -74,7 +74,10 @@ Component Radiobox(ConstStringListRef entries, int* selected_, RadioboxOption options = {}); -Component Dropdown(ConstStringListRef entries, int* selected, DropdownOption options = {}); +Component Dropdown(ConstStringListRef entries, + int* selected, + DropdownOption options = {}); + Component Toggle(ConstStringListRef entries, int* selected); // General slider constructor: diff --git a/include/ftxui/component/component_options.hpp b/include/ftxui/component/component_options.hpp index 80480c423..1f4990ae4 100644 --- a/include/ftxui/component/component_options.hpp +++ b/include/ftxui/component/component_options.hpp @@ -151,7 +151,6 @@ struct CheckboxOption { /// @brief Option for the Dropdown component. /// @ingroup component struct DropdownOption { - bool border = true; // Observer: From 60ba15ac07877bf78d30e809e270791cbe0247d4 Mon Sep 17 00:00:00 2001 From: ArthurSonzogni Date: Mon, 18 Mar 2024 23:00:21 +0100 Subject: [PATCH 4/8] Add full customization. --- examples/component/CMakeLists.txt | 1 + examples/component/dropdown_custom.cpp | 69 +++++++++ include/ftxui/component/component.hpp | 5 +- include/ftxui/component/component_options.hpp | 20 +-- src/ftxui/component/dropdown.cpp | 132 +++++++++--------- 5 files changed, 150 insertions(+), 77 deletions(-) create mode 100644 examples/component/dropdown_custom.cpp diff --git a/examples/component/CMakeLists.txt b/examples/component/CMakeLists.txt index 661fee06e..5d80fd8d6 100644 --- a/examples/component/CMakeLists.txt +++ b/examples/component/CMakeLists.txt @@ -11,6 +11,7 @@ example(collapsible) example(composition) example(custom_loop) example(dropdown) +example(dropdown_custom) example(flexbox_gallery) example(focus) example(focus_cursor) diff --git a/examples/component/dropdown_custom.cpp b/examples/component/dropdown_custom.cpp new file mode 100644 index 000000000..e07581d14 --- /dev/null +++ b/examples/component/dropdown_custom.cpp @@ -0,0 +1,69 @@ +// 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. +#include // for basic_string, string, allocator +#include // for vector + +#include "ftxui/component/captured_mouse.hpp" // for ftxui +#include "ftxui/component/component.hpp" // for Dropdown, Horizontal, Vertical +#include "ftxui/component/screen_interactive.hpp" // for ScreenInteractive + +int main() { + using namespace ftxui; + + std::vector entries = { + "tribute", "clearance", "ally", "bend", "electronics", + "module", "era", "cultural", "sniff", "nationalism", + "negotiation", "deliver", "figure", "east", "tribute", + "clearance", "ally", "bend", "electronics", "module", + "era", "cultural", "sniff", "nationalism", "negotiation", + "deliver", "figure", "east", "tribute", "clearance", + "ally", "bend", "electronics", "module", "era", + "cultural", "sniff", "nationalism", "negotiation", "deliver", + "figure", "east", + }; + + auto dropdown_1 = Dropdown({ + .radiobox = {.entries = &entries}, + .transform = + [](bool open, Element checkbox, Element radiobox) { + if (open) { + return vbox({ + checkbox | inverted, + radiobox | vscroll_indicator | frame | + size(HEIGHT, LESS_THAN, 10), + filler(), + }); + } + return vbox({ + checkbox, + filler(), + }); + }, + }); + + auto dropdown_2 = Dropdown({ + .radiobox = {.entries = &entries}, + .transform = + [](bool open, Element checkbox, Element radiobox) { + if (open) { + return vbox({ + checkbox | inverted, + radiobox | vscroll_indicator | frame | + size(HEIGHT, LESS_THAN, 10) | bgcolor(Color::Blue), + filler(), + }); + } + return vbox({ + checkbox | bgcolor(Color::Blue), + filler(), + }); + }, + }); + + auto screen = ScreenInteractive::FitComponent(); + screen.Loop(Container::Horizontal({ + dropdown_1, + dropdown_2, + })); +} diff --git a/include/ftxui/component/component.hpp b/include/ftxui/component/component.hpp index fd4aec02b..36eb605cb 100644 --- a/include/ftxui/component/component.hpp +++ b/include/ftxui/component/component.hpp @@ -74,9 +74,8 @@ Component Radiobox(ConstStringListRef entries, int* selected_, RadioboxOption options = {}); -Component Dropdown(ConstStringListRef entries, - int* selected, - DropdownOption options = {}); +Component Dropdown(ConstStringListRef entries, int* selected); +Component Dropdown(DropdownOption options); Component Toggle(ConstStringListRef entries, int* selected); diff --git a/include/ftxui/component/component_options.hpp b/include/ftxui/component/component_options.hpp index 1f4990ae4..881a98294 100644 --- a/include/ftxui/component/component_options.hpp +++ b/include/ftxui/component/component_options.hpp @@ -148,15 +148,6 @@ struct CheckboxOption { std::function on_change = [] {}; }; -/// @brief Option for the Dropdown component. -/// @ingroup component -struct DropdownOption { - bool border = true; - - // Observer: - /// Called when the user change the state. - std::function on_change = [] {}; -}; /// @brief Used to define style for the Input component. struct InputState { @@ -273,6 +264,17 @@ struct WindowOptions { std::function render; }; +/// @brief Option for the Dropdown component. +/// @ingroup component +/// A dropdown menu is a checkbox opening/closing a radiobox. +struct DropdownOption { + Ref open = false; + CheckboxOption checkbox; + RadioboxOption radiobox; + std::function + transform; +}; + } // namespace ftxui #endif /* end of include guard: FTXUI_COMPONENT_COMPONENT_OPTIONS_HPP */ diff --git a/src/ftxui/component/dropdown.cpp b/src/ftxui/component/dropdown.cpp index 7602334b6..2ff5c22f6 100644 --- a/src/ftxui/component/dropdown.cpp +++ b/src/ftxui/component/dropdown.cpp @@ -19,100 +19,102 @@ namespace ftxui { /// @ingroup component /// @param entries The list of entries to display. /// @param selected The index of the selected entry. -Component Dropdown(ConstStringListRef entries, int* selected, DropdownOption option) { - class Impl : public ComponentBase { +Component Dropdown(ConstStringListRef entries, int* selected) { + DropdownOption option; + option.radiobox.entries = entries; + option.radiobox.selected = selected; + return Dropdown(option); +} + +/// @brief A dropdown menu. +/// @ingroup component +/// @param option The options for the dropdown. +Component Dropdown(DropdownOption option) { + class Impl : public ComponentBase, public DropdownOption { public: - Impl(ConstStringListRef entries, int* selected, DropdownOption dropDownOption) - : entries_(entries), selected_(selected) { - CheckboxOption option; - option.transform = [](const EntryState& s) { - auto prefix = text(s.state ? "↓ " : "→ "); // NOLINT - auto t = text(s.label); - if (s.active) { - t |= bold; - } - if (s.focused) { - t |= inverted; - } - return hbox({prefix, t}); - }; - checkbox_ = Checkbox(&title_, &show_, option); - - RadioboxOption radioboxOption; - radioboxOption.on_change = dropDownOption.on_change; - - radiobox_ = Radiobox(entries_, selected_, radioboxOption); + Impl(DropdownOption option) : DropdownOption(std::move(option)) { + FillDefault(); + checkbox_ = Checkbox(checkbox); + radiobox_ = Radiobox(radiobox); Add(Container::Vertical({ checkbox_, - Maybe(radiobox_, &show_), + Maybe(radiobox_, checkbox.checked), })); - - border_ = dropDownOption.border; } Element Render() override { - *selected_ = util::clamp(*selected_, 0, int(entries_.size()) - 1); - title_ = entries_[static_cast(*selected_)]; - if (show_) { - const int max_height = 12; - auto element = vbox({ - checkbox_->Render(), - separator(), - radiobox_->Render() | vscroll_indicator | frame | - size(HEIGHT, LESS_THAN, max_height), - }); - - if (border_) - { - element |= border; - } - - return element; - } - - auto element = checkbox_->Render(); + radiobox.selected = + util::clamp(radiobox.selected(), 0, int(radiobox.entries.size()) - 1); + checkbox.label = + radiobox.entries[static_cast(radiobox.selected())]; - if (border_) - { - element |= border; - } - - return vbox({ - element, - filler(), - }); + return transform(*open_, checkbox_->Render(), radiobox_->Render()); } // 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 show_old = open_(); + const int selected_old = selected_(); const bool handled = ComponentBase::OnEvent(event); - if (!show_old && show_) { + if (!show_old && open_()) { radiobox_->TakeFocus(); } - if (selected_old != *selected_) { + if (selected_old != selected_()) { checkbox_->TakeFocus(); - show_ = false; + open_ = false; } return handled; } + void FillDefault() { + open_ = std::move(checkbox.checked); + selected_ = std::move(radiobox.selected); + checkbox.checked = &*open_; + radiobox.selected = &*selected_; + + if (!checkbox.transform) { + checkbox.transform = [](const EntryState& s) { + auto prefix = text(s.state ? "↓ " : "→ "); // NOLINT + auto t = text(s.label); + if (s.active) { + t |= bold; + } + if (s.focused) { + t |= inverted; + } + return hbox({prefix, t}); + }; + } + + if (!transform) { + transform = [](bool open, Element checkbox, Element radiobox) { + if (open) { + const int max_height = 12; + return vbox({ + checkbox, + separator(), + radiobox | vscroll_indicator | frame | + size(HEIGHT, LESS_THAN, max_height), + }) | + border; + } + return vbox({checkbox, filler()}) | border; + }; + } + } + private: - ConstStringListRef entries_; - bool show_ = false; - bool border_ = true; - int* selected_; - std::string title_; + Ref open_; + Ref selected_; Component checkbox_; Component radiobox_; }; - return Make(entries, selected, option); + return Make(option); } } // namespace ftxui From 803cfda875cf85e3c3df15cde60a8589617194e8 Mon Sep 17 00:00:00 2001 From: James Parker Date: Thu, 4 Apr 2024 08:28:56 +0100 Subject: [PATCH 5/8] Fix shadowed vars --- src/ftxui/component/dropdown.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/ftxui/component/dropdown.cpp b/src/ftxui/component/dropdown.cpp index 2ff5c22f6..3438070ef 100644 --- a/src/ftxui/component/dropdown.cpp +++ b/src/ftxui/component/dropdown.cpp @@ -91,18 +91,18 @@ Component Dropdown(DropdownOption option) { } if (!transform) { - transform = [](bool open, Element checkbox, Element radiobox) { - if (open) { + transform = [](bool _open, Element _checkbox, Element _radiobox) { + if (_open) { const int max_height = 12; return vbox({ - checkbox, + _checkbox, separator(), - radiobox | vscroll_indicator | frame | + _radiobox | vscroll_indicator | frame | size(HEIGHT, LESS_THAN, max_height), }) | border; } - return vbox({checkbox, filler()}) | border; + return vbox({_checkbox, filler()}) | border; }; } } From c71cf3e4bf763c04910fa3b83441fc811a575621 Mon Sep 17 00:00:00 2001 From: ArthurSonzogni Date: Mon, 1 Apr 2024 21:14:24 +0200 Subject: [PATCH 6/8] Fix dropdown compiler error --- src/ftxui/component/dropdown.cpp | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/src/ftxui/component/dropdown.cpp b/src/ftxui/component/dropdown.cpp index 3438070ef..e2de91c71 100644 --- a/src/ftxui/component/dropdown.cpp +++ b/src/ftxui/component/dropdown.cpp @@ -91,18 +91,19 @@ Component Dropdown(DropdownOption option) { } if (!transform) { - transform = [](bool _open, Element _checkbox, Element _radiobox) { - if (_open) { + transform = [](bool open, Element checkbox_element, + Element radiobox_element) { + if (open) { const int max_height = 12; return vbox({ - _checkbox, + checkbox_element, separator(), - _radiobox | vscroll_indicator | frame | + radiobox_element | vscroll_indicator | frame | size(HEIGHT, LESS_THAN, max_height), }) | border; } - return vbox({_checkbox, filler()}) | border; + return vbox({checkbox_element, filler()}) | border; }; } } From 5ff0764e77bf7b903908354b518c8da3320d0986 Mon Sep 17 00:00:00 2001 From: ArthurSonzogni Date: Sat, 6 Apr 2024 17:41:43 +0200 Subject: [PATCH 7/8] Add changelog and example. --- CHANGELOG.md | 1 + examples/component/dropdown_custom.cpp | 35 +++++++++++++++++++ include/ftxui/component/component_options.hpp | 4 +++ 3 files changed, 40 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 4963ac57e..17dff7c68 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,7 @@ current (development) ### Component - Feature: Add support for `Input`'s insert mode. Add `InputOption::insert` option. Added by @mingsheng13. +- Feature: Add `DropdownOption` to configure the dropdown. See #826. - Bugfix/Breaking change: `Mouse transition`: - Detect when the mouse move, as opposed to being pressed. The Mouse::Moved motion was added. diff --git a/examples/component/dropdown_custom.cpp b/examples/component/dropdown_custom.cpp index e07581d14..462d7f7b4 100644 --- a/examples/component/dropdown_custom.cpp +++ b/examples/component/dropdown_custom.cpp @@ -61,9 +61,44 @@ int main() { }, }); + auto dropdown_3 = Dropdown({ + .radiobox = + { + .entries = &entries, + .transform = + [](const EntryState& s) { + auto t = text(s.label) | borderEmpty; + if (s.active) { + t |= bold; + } + if (s.focused) { + t |= inverted; + } + return t; + }, + }, + .transform = + [](bool open, Element checkbox, Element radiobox) { + checkbox |= borderEmpty; + if (open) { + return vbox({ + checkbox | inverted, + radiobox | vscroll_indicator | frame | + size(HEIGHT, LESS_THAN, 20) | bgcolor(Color::Red), + filler(), + }); + } + return vbox({ + checkbox | bgcolor(Color::Red), + filler(), + }); + }, + }); + auto screen = ScreenInteractive::FitComponent(); screen.Loop(Container::Horizontal({ dropdown_1, dropdown_2, + dropdown_3, })); } diff --git a/include/ftxui/component/component_options.hpp b/include/ftxui/component/component_options.hpp index 881a98294..100a99d9a 100644 --- a/include/ftxui/component/component_options.hpp +++ b/include/ftxui/component/component_options.hpp @@ -268,9 +268,13 @@ struct WindowOptions { /// @ingroup component /// A dropdown menu is a checkbox opening/closing a radiobox. struct DropdownOption { + /// Whether the dropdown is open or closed: Ref open = false; + // The options for the checkbox: CheckboxOption checkbox; + // The options for the radiobox: RadioboxOption radiobox; + // The transformation function: std::function transform; }; From 07a390ee631b72d32c187cc8e4bdd9c404297470 Mon Sep 17 00:00:00 2001 From: ArthurSonzogni Date: Sat, 6 Apr 2024 17:44:40 +0200 Subject: [PATCH 8/8] Apply IWYU --- examples/component/homescreen.cpp | 10 +++++----- include/ftxui/component/component.hpp | 2 +- include/ftxui/component/component_options.hpp | 1 - src/ftxui/component/button.cpp | 6 +++--- src/ftxui/component/screen_interactive.cpp | 8 ++++---- 5 files changed, 13 insertions(+), 14 deletions(-) diff --git a/examples/component/homescreen.cpp b/examples/component/homescreen.cpp index 1af03a5d5..d335fabfa 100644 --- a/examples/component/homescreen.cpp +++ b/examples/component/homescreen.cpp @@ -494,11 +494,11 @@ int main() { "Exit", [&] { screen.Exit(); }, ButtonOption::Animated()); auto main_container = Container::Vertical({ - Container::Horizontal({ - tab_selection, - exit_button, - }), - tab_content, + Container::Horizontal({ + tab_selection, + exit_button, + }), + tab_content, }); auto main_renderer = Renderer(main_container, [&] { diff --git a/include/ftxui/component/component.hpp b/include/ftxui/component/component.hpp index 36eb605cb..d9b709987 100644 --- a/include/ftxui/component/component.hpp +++ b/include/ftxui/component/component.hpp @@ -76,7 +76,7 @@ Component Radiobox(ConstStringListRef entries, Component Dropdown(ConstStringListRef entries, int* selected); Component Dropdown(DropdownOption options); - + Component Toggle(ConstStringListRef entries, int* selected); // General slider constructor: diff --git a/include/ftxui/component/component_options.hpp b/include/ftxui/component/component_options.hpp index 100a99d9a..73b8a0e08 100644 --- a/include/ftxui/component/component_options.hpp +++ b/include/ftxui/component/component_options.hpp @@ -148,7 +148,6 @@ struct CheckboxOption { std::function on_change = [] {}; }; - /// @brief Used to define style for the Input component. struct InputState { Element element; diff --git a/src/ftxui/component/button.cpp b/src/ftxui/component/button.cpp index f16dcf442..04a7f84bb 100644 --- a/src/ftxui/component/button.cpp +++ b/src/ftxui/component/button.cpp @@ -104,7 +104,7 @@ class ButtonBase : public ComponentBase, public ButtonOption { // TODO(arthursonzogni): Consider posting the task to the main loop, instead // of invoking it immediately. - on_click(); // May delete this. + on_click(); // May delete this. } bool OnEvent(Event event) override { @@ -113,7 +113,7 @@ class ButtonBase : public ComponentBase, public ButtonOption { } if (event == Event::Return) { - OnClick(); // May delete this. + OnClick(); // May delete this. return true; } return false; @@ -130,7 +130,7 @@ class ButtonBase : public ComponentBase, public ButtonOption { if (event.mouse().button == Mouse::Left && event.mouse().motion == Mouse::Pressed) { TakeFocus(); - OnClick(); // May delete this. + OnClick(); // May delete this. return true; } diff --git a/src/ftxui/component/screen_interactive.cpp b/src/ftxui/component/screen_interactive.cpp index dc729acb3..1e1125f7e 100644 --- a/src/ftxui/component/screen_interactive.cpp +++ b/src/ftxui/component/screen_interactive.cpp @@ -848,13 +848,13 @@ void ScreenInteractive::Draw(Component component) { reset_cursor_position.clear(); if (dy != 0) { - set_cursor_position += "\x1B[" + std::to_string(dy) + "A"; - reset_cursor_position += "\x1B[" + std::to_string(dy) + "B"; + set_cursor_position += "\x1B[" + std::to_string(dy) + "A"; + reset_cursor_position += "\x1B[" + std::to_string(dy) + "B"; } if (dx != 0) { - set_cursor_position += "\x1B[" + std::to_string(dx) + "D"; - reset_cursor_position += "\x1B[" + std::to_string(dx) + "C"; + set_cursor_position += "\x1B[" + std::to_string(dx) + "D"; + reset_cursor_position += "\x1B[" + std::to_string(dx) + "C"; } if (cursor_.shape == Cursor::Hidden) {