diff options
author | RĂ©mi Verschelde <rverschelde@gmail.com> | 2017-12-17 20:22:50 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-12-17 20:22:50 +0100 |
commit | 1ef123c57db0ab5f6395dd5e206234b0ed03f7b6 (patch) | |
tree | 0458effa8c3bef984de1d88914146ddc854c8ca8 /scene/gui | |
parent | 90d95c7ee17b94736045555f1810a2a920fd3b33 (diff) | |
parent | c19cc581ec1e6fc30c3df48f7683a96436c1db06 (diff) |
Merge pull request #14748 from YeldhamDev/popupmenu_circleback
Made highlighted item in PopupMenu circle back to the beginning/end when using the keyboard
Diffstat (limited to 'scene/gui')
-rw-r--r-- | scene/gui/popup_menu.cpp | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/scene/gui/popup_menu.cpp b/scene/gui/popup_menu.cpp index 62f2b15ddd..d598104cf5 100644 --- a/scene/gui/popup_menu.cpp +++ b/scene/gui/popup_menu.cpp @@ -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; |