ppizarror / pygame-menu

A menu for pygame. Simple, and easy to use
https://pygame-menu.readthedocs.io/
Other
544 stars 141 forks source link

AttributeError when changing rangeslider value with an USB gamepad #478

Open derUli opened 7 months ago

derUli commented 7 months ago

Environment information Describe your environment information, such as:

Describe the bug pygame-menu crashes when changing a rangeslider's value using a controller.

  File "C:\Users\useraccount\AppData\Roaming\Python\Python311\site-packages\pygame_menu\menu.py", line 3027, in mainloop
    self.update(pygame.event.get())
  File "C:\Users\useraccount\AppData\Roaming\Python\Python311\site-packages\pygame_menu\menu.py", line 2566, in update
    selected_widget.update_menu(events)
  File "C:\Users\useraccount\AppData\Roaming\Python\Python311\site-packages\pygame_menu\widgets\core\widget.py", line 2762, in update_menu
    return self.update(events)
           ^^^^^^^^^^^^^^^^^^^
  File "C:\Users\useraccount\AppData\Roaming\Python\Python311\site-packages\pygame_menu\widgets\widget\rangeslider.py", line 962, in update
    if self._left_right(event, True):
       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\useraccount\AppData\Roaming\Python\Python311\site-packages\pygame_menu\widgets\widget\rangeslider.py", line 880, in _left_right
    if event.key not in self._keyrepeat_counters:
       ^^^^^^^^^
AttributeError: 'pygame.event.Event' object has no attribute 'key'

To Reproduce Just make a pygame-menu with a rangeslider. Run the app and try to change the value using the left stick or arrow keys of an USB gaming controller.

Expected behavior Should change the value like it does when pressing left arrow or right arrow on a PC keyboard.

Additional context I am using an Xbox 360 style USB gaming controller. But it seems to be a general error not related to specific hardware.