Merge pull request #14748 from YeldhamDev/popupmenu_circleback
Made highlighted item in PopupMenu circle back to the beginning/end when using the keyboard
This commit is contained in:
commit
1ef123c57d
|
@ -202,7 +202,11 @@ void PopupMenu::_gui_input(const Ref<InputEvent> &p_event) {
|
|||
|
||||
case KEY_DOWN: {
|
||||
|
||||
for (int i = mouse_over + 1; i < items.size(); i++) {
|
||||
int search_from = mouse_over + 1;
|
||||
if (search_from >= items.size())
|
||||
search_from = 0;
|
||||
|
||||
for (int i = search_from; i < items.size(); i++) {
|
||||
|
||||
if (i < 0 || i >= items.size())
|
||||
continue;
|
||||
|
@ -217,7 +221,11 @@ void PopupMenu::_gui_input(const Ref<InputEvent> &p_event) {
|
|||
} break;
|
||||
case KEY_UP: {
|
||||
|
||||
for (int i = mouse_over - 1; i >= 0; i--) {
|
||||
int search_from = mouse_over - 1;
|
||||
if (search_from < 0)
|
||||
search_from = items.size() - 1;
|
||||
|
||||
for (int i = search_from; i >= 0; i--) {
|
||||
|
||||
if (i < 0 || i >= items.size())
|
||||
continue;
|
||||
|
|
Loading…
Reference in New Issue