Closed FractalWire closed 5 years ago
This isn't a bug, SDL2 doesn't return the mouse position on a mouse wheel event (but it does on a wheel click.)
The tcod.sys_check_for_event
returns the events type, this should be used instead of giving it a partial event mask, like in the following example:
def handle_events(events):
key = tcod.Key()
mouse = tcod.Mouse()
while True:
ev = tcod.sys_check_for_event(tcod.EVENT_ANY, key, mouse)
if not ev:
break
if ev & tcod.EVENT_KEY_PRESS:
if key.vk == tcod.KEY_ESCAPE:
raise SystemExit()
if ev & tcod.EVENT_MOUSE_MOVE:
print(mouse.cx,mouse.cy,mouse.x,mouse.y)
Actually, I might have been too quick to judge this. This could a regression in behavior, since mouse wheel events are put into TCOD_EVENT_MOUSE_PRESS
for some reason.
The regression is fixed in 8.4.1 and in libtcod. Mouse wheel events in libtcodpy are now back to their usual undefined behavior of preserving coordinates from previous mouse events.
Perfect, thanks !
Hello again,
I have a new problem, this time with the wheel event. I have a handle_events() function that could look like this :
Everything is fine when I move my mouse around, but when I wheel up/down, the value printed are 0 (except the last one=1 for some reason) So it seems to reset the mouse position whenever I wheel up/down.