]> git.lizzy.rs Git - nothing.git/commitdiff
Don't select the level when cursor doesn't point at anything
authorrexim <reximkut@gmail.com>
Sun, 15 Dec 2019 17:35:56 +0000 (00:35 +0700)
committerrexim <reximkut@gmail.com>
Sun, 15 Dec 2019 17:35:56 +0000 (00:35 +0700)
src/ui/list_selector.c

index 3b94cba01247c5043372a4753d7315da42413230..03fc46c3c3cfc56ce3f4a907dacae90f5ec2ef65 100644 (file)
@@ -101,7 +101,9 @@ int list_selector_event(ListSelector *list_selector, const SDL_Event *event)
             }
             break;
         case SDLK_RETURN:
-            list_selector->selected_item = (int) list_selector->cursor;
+            if (list_selector->cursor < list_selector->items.count) {
+                list_selector->selected_item = (int) list_selector->cursor;
+            }
             break;
         }
         break;