Skip to content

Commit 7dc1179

Browse files
committed
Always use keywords in structural pattern matching.
The docs were erroneously using positional arguments, but this is not supported by the current classes. Related to #120.
1 parent db937cd commit 7dc1179

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed

tcod/event.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -68,11 +68,11 @@
6868
raise SystemExit()
6969
case tcod.event.KeyDown(sym) if sym in KEY_COMMANDS:
7070
print(f"Command: {KEY_COMMANDS[sym]}")
71-
case tcod.event.KeyDown(sym, scancode, mod, repeat):
71+
case tcod.event.KeyDown(sym=sym, scancode=scancode, mod=mod, repeat=repeat):
7272
print(f"KeyDown: {sym=}, {scancode=}, {mod=}, {repeat=}")
73-
case tcod.event.MouseButtonDown(button, pixel, tile):
73+
case tcod.event.MouseButtonDown(button=button, pixel=pixel, tile=tile):
7474
print(f"MouseButtonDown: {button=}, {pixel=}, {tile=}")
75-
case tcod.event.MouseMotion(pixel, pixel_motion, tile, tile_motion):
75+
case tcod.event.MouseMotion(pixel=pixel, pixel_motion=pixel_motion, tile=tile, tile_motion=tile_motion):
7676
print(f"MouseMotion: {pixel=}, {pixel_motion=}, {tile=}, {tile_motion=}")
7777
case tcod.event.Event() as event:
7878
print(event) # Show any unhandled events.

tcod/sdl/mouse.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -151,12 +151,12 @@ def capture(enable: bool) -> None:
151151
# This means that dragging the mouse outside of the window will not cause an interruption in motion events.
152152
for event in tcod.event.get():
153153
match event:
154-
case tcod.event.MouseButtonDown(button, pixel): # Clicking the window captures the mouse.
154+
case tcod.event.MouseButtonDown(button=button, pixel=pixel): # Clicking the window captures the mouse.
155155
tcod.sdl.mouse.capture(True)
156156
case tcod.event.MouseButtonUp(): # When all buttons are released then the mouse is released.
157157
if tcod.event.mouse.get_global_state().state == 0:
158158
tcod.sdl.mouse.capture(False)
159-
case tcod.event.MouseMotion(pixel, pixel_motion, state):
159+
case tcod.event.MouseMotion(pixel=pixel, pixel_motion=pixel_motion, state=state):
160160
pass # While a button is held this event is still captured outside of the window.
161161
162162
.. seealso::

0 commit comments

Comments
 (0)