diff --git a/squirrelbattle/display/menudisplay.py b/squirrelbattle/display/menudisplay.py index d745c28..eee4606 100644 --- a/squirrelbattle/display/menudisplay.py +++ b/squirrelbattle/display/menudisplay.py @@ -48,7 +48,7 @@ class MenuDisplay(Display): """ We can select a menu item with the mouse. """ - self.menu.position = y - 1 + self.menu.position = max(0, min(len(self.menu.values) - 1, y - 1)) game.handle_key_pressed(KeyValues.ENTER) @property @@ -136,3 +136,10 @@ class InventoryDisplay(MenuDisplay): @property def trueheight(self) -> int: return 2 + super().trueheight + + def handle_click(self, y: int, x: int, game: Game) -> None: + """ + We can select a menu item with the mouse. + """ + self.menu.position = max(0, min(len(self.menu.values) - 1, y - 3)) + game.handle_key_pressed(KeyValues.ENTER)