Skip to content

Commit

Permalink
modify sections to accept bools for prevent_dispatch and `prevent_d…
Browse files Browse the repository at this point in the history
…ispatch_view`
  • Loading branch information
DragonMoffon committed Jan 23, 2025
1 parent ad9eaab commit 675e94d
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions arcade/sections.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,8 @@ def __init__(
name: str | None = None,
accept_keyboard_keys: bool | Iterable = True,
accept_mouse_events: bool | Iterable = True,
prevent_dispatch: Iterable | None = None,
prevent_dispatch_view: Iterable | None = None,
prevent_dispatch: Iterable | bool | None = None,
prevent_dispatch_view: Iterable | bool | None = None,
local_mouse_coordinates: bool = False,
enabled: bool = True,
modal: bool = False,
Expand Down Expand Up @@ -96,10 +96,14 @@ def __init__(
self.accept_mouse_events: bool | Iterable = accept_mouse_events
"""Arcade mouse events to accept."""

if isinstance(prevent_dispatch, bool):
prevent_dispatch = {prevent_dispatch}
self.prevent_dispatch: Iterable = {True} if prevent_dispatch is None else prevent_dispatch
assert isinstance(self.prevent_dispatch, Iterable)
"""prevents events to propagate"""

if isinstance(prevent_dispatch_view, bool):
prevent_dispatch_view = {prevent_dispatch_view}
self.prevent_dispatch_view: Iterable = (
{True} if prevent_dispatch_view is None else prevent_dispatch_view
)
Expand Down

0 comments on commit 675e94d

Please sign in to comment.