-
|
I was poking around coding and noticed problem. If the loop is while running:
while sdl3.SDL_PollEvent(ctypes.byref(event)) != 0:
result = event_handling.react(event)
if event.type == sdl3.SDL_EVENT_QUIT or result == sdl3.SDL_EVENT_QUIT:
running = False
breakAnd I have event_handling.react as instance running from different file import sdl3
class EventsHandler:
def __init__(self):
self.action = None
def react(self, key):
self.action = sdl3.SDL_DEREFERENCE(key).type
match self.action:
case sdl3.SDL_EVENT_KEY_DOWN:
if self.action.key.scancode == sdl3.SDL_SCANCODE_Q:
return sdl3.SDL_APP_SUCCESS
return self.action
case sdl3.SDL_EVENT_KEY_UP:
if self.action.key.scancode == sdl3.SDL_SCANCODE_Q:
return sdl3.SDL_APP_SUCCESS
return self.action
case _:
return self.actionIt will give AttributeError: 'int' object has no attribute 'key', but still work as expected. |
Beta Was this translation helpful? Give feedback.
Answered by
Ausreich
Jun 29, 2025
Replies: 1 comment
-
|
You're trying to access the def react(self, event: sdl3.SDL_Event) -> sdl3.SDL_AppResult:
match event.type:
case sdl3.SDL_EVENT_KEY_DOWN:
if event.key.scancode in [sdl3.SDL_SCANCODE_Q]:
return sdl3.SDL_APP_SUCCESS
return sdl3.SDL_APP_CONTINUE |
Beta Was this translation helpful? Give feedback.
0 replies
Answer selected by
Ausreich
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
You're trying to access the
keyvariable fromSDL_Event.typeinstead ofSDL_Event.