Skip to content

Commit

Permalink
Pass index for selection
Browse files Browse the repository at this point in the history
  • Loading branch information
horrifyingHorse committed Dec 27, 2024
1 parent 81578f9 commit b148798
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
5 changes: 3 additions & 2 deletions src/ftxui/component/menu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -143,8 +143,9 @@ class MenuBase : public ComponentBase, public MenuOption {
std::reverse(elements.begin(), elements.end());
}

const Element bar =
IsHorizontal() ? hbox(std::move(elements)) : vbox(std::move(elements));
const Element bar = IsHorizontal()
? hbox(std::move(elements), focused_entry())
: vbox(std::move(elements), focused_entry());

if (!underline.enabled) {
return bar | reflect(box_);
Expand Down
5 changes: 2 additions & 3 deletions src/ftxui/component/radiobox.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,7 @@ class RadioboxBase : public ComponentBase, public RadioboxOption {
for (int i = 0; i < size(); ++i) {
const bool is_focused = (focused_entry() == i) && is_menu_focused;
const bool is_selected = (hovered_ == i);
auto focus_management = !is_selected ? nothing
: select;
auto focus_management = is_selected ? select : nothing;
auto state = EntryState{
entries[i], selected() == i, is_selected, is_focused, i,
};
Expand All @@ -46,7 +45,7 @@ class RadioboxBase : public ComponentBase, public RadioboxOption {

elements.push_back(element | focus_management | reflect(boxes_[i]));
}
return vbox(std::move(elements)) | reflect(box_);
return vbox(std::move(elements), focused_entry()) | reflect(box_);
}

// NOLINTNEXTLINE(readability-function-cognitive-complexity)
Expand Down

0 comments on commit b148798

Please sign in to comment.