docs: Add missing Drawable callbacks and Scene.on_key to stubs

Add to Drawable base class:
- on_click, on_enter, on_exit, on_move callbacks (#140, #141)
- hovered read-only property (#140)

Add to Scene class:
- children property (#151)
- on_key handler property

Discovered while defining implementation details for #143.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
John McCardle 2025-12-28 14:49:17 -05:00
commit 89986323f8
2 changed files with 64 additions and 42 deletions

View file

@ -83,6 +83,15 @@ class Drawable:
name: str
pos: Vector
# Mouse event callbacks (#140, #141)
on_click: Optional[Callable[[float, float, int, str], None]]
on_enter: Optional[Callable[[float, float, int, str], None]]
on_exit: Optional[Callable[[float, float, int, str], None]]
on_move: Optional[Callable[[float, float, int, str], None]]
# Read-only hover state (#140)
hovered: bool
def get_bounds(self) -> Tuple[float, float, float, float]:
"""Get bounding box as (x, y, width, height)."""
...
@ -333,6 +342,8 @@ class Scene:
"""Base class for object-oriented scenes."""
name: str
children: UICollection # #151: UI elements collection (read-only alias for get_ui())
on_key: Optional[Callable[[str, str], None]] # Keyboard handler (key, action)
def __init__(self, name: str) -> None: ...
@ -349,27 +360,27 @@ class Scene:
...
def on_keypress(self, key: str, pressed: bool) -> None:
"""Handle keyboard events."""
"""Handle keyboard events (override in subclass)."""
...
def on_click(self, x: float, y: float, button: int) -> None:
"""Handle mouse clicks."""
"""Handle mouse clicks (override in subclass)."""
...
def on_enter(self) -> None:
"""Called when entering the scene."""
"""Called when entering the scene (override in subclass)."""
...
def on_exit(self) -> None:
"""Called when leaving the scene."""
"""Called when leaving the scene (override in subclass)."""
...
def on_resize(self, width: int, height: int) -> None:
"""Handle window resize events."""
"""Handle window resize events (override in subclass)."""
...
def update(self, dt: float) -> None:
"""Update scene logic."""
"""Update scene logic (override in subclass)."""
...
class Timer:

View file

@ -95,6 +95,15 @@ class Drawable:
name: str
pos: Vector
# Mouse event callbacks (#140, #141)
on_click: Optional[Callable[[float, float, int, str], None]]
on_enter: Optional[Callable[[float, float, int, str], None]]
on_exit: Optional[Callable[[float, float, int, str], None]]
on_move: Optional[Callable[[float, float, int, str], None]]
# Read-only hover state (#140)
hovered: bool
def get_bounds(self) -> Tuple[float, float, float, float]:
"""Get bounding box as (x, y, width, height)."""
...
@ -345,6 +354,8 @@ class Scene:
"""Base class for object-oriented scenes."""
name: str
children: UICollection # #151: UI elements collection (read-only alias for get_ui())
on_key: Optional[Callable[[str, str], None]] # Keyboard handler (key, action)
def __init__(self, name: str) -> None: ...
@ -361,27 +372,27 @@ class Scene:
...
def on_keypress(self, key: str, pressed: bool) -> None:
"""Handle keyboard events."""
"""Handle keyboard events (override in subclass)."""
...
def on_click(self, x: float, y: float, button: int) -> None:
"""Handle mouse clicks."""
"""Handle mouse clicks (override in subclass)."""
...
def on_enter(self) -> None:
"""Called when entering the scene."""
"""Called when entering the scene (override in subclass)."""
...
def on_exit(self) -> None:
"""Called when leaving the scene."""
"""Called when leaving the scene (override in subclass)."""
...
def on_resize(self, width: int, height: int) -> None:
"""Handle window resize events."""
"""Handle window resize events (override in subclass)."""
...
def update(self, dt: float) -> None:
"""Update scene logic."""
"""Update scene logic (override in subclass)."""
...
class Timer: