ArthurSonzogni / FTXUI

:computer: C++ Functional Terminal User Interface. :heart:
MIT License
7.02k stars 428 forks source link

Toggle not highlighting the selected option #721

Open mingsheng13 opened 1 year ago

mingsheng13 commented 1 year ago

Toggle will always highlight the first option rather than the actually selected one. When the selected is the last option, right arrow key will not change the highlight to the last option and stuck to the first one instead.

ArthurSonzogni commented 1 year ago

Hi @mingsheng13, Thanks for opening an issue!

I can't really see any problems locally. Would you have some code example I could try to investigate?

mingsheng13 commented 1 year ago

containerbug

I change the initial value of the selector in the example code. When I first run the code, the highlighted option is not the one that is selected.

To reproduce:

I changed https://github.com/ArthurSonzogni/FTXUI/blob/8d1665022a45352202904d9f47b3b30ef04d44eb/examples/component/toggle.cpp#L35C17-L38 to

  int toggle_1_selected = 0;
  int toggle_2_selected = 1;
  int toggle_3_selected = 0;
  int toggle_4_selected = 3;