feat: Implement comprehensive mouse event system

Implements multiple mouse event improvements for UI elements:

- Mouse enter/exit events (#140): on_enter, on_exit callbacks and
  hovered property for all UIDrawable types (Frame, Caption, Sprite, Grid)
- Headless click events (#111): Track simulated mouse position for
  automation testing in headless mode
- Mouse move events (#141): on_move callback fires continuously while
  mouse is within element bounds
- Grid cell events (#142): on_cell_enter, on_cell_exit, on_cell_click
  callbacks with cell coordinates (x, y), plus hovered_cell property

Includes comprehensive tests for all new functionality.

Closes #140, closes #111, closes #141, closes #142

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

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
John McCardle 2025-11-27 23:08:31 -05:00
commit 6c496b8732
14 changed files with 1353 additions and 27 deletions

View file

@ -183,6 +183,27 @@ static int UIDrawable_set_opacity(T* self, PyObject* value, void* closure)
{"global_bounds", (getter)UIDrawable::get_global_bounds_py, NULL, \
MCRF_PROPERTY(global_bounds, \
"Bounding rectangle (x, y, width, height) in screen coordinates." \
), (void*)type_enum}, \
{"on_enter", (getter)UIDrawable::get_on_enter, (setter)UIDrawable::set_on_enter, \
MCRF_PROPERTY(on_enter, \
"Callback for mouse enter events. " \
"Called with (x, y, button, action) when mouse enters this element's bounds." \
), (void*)type_enum}, \
{"on_exit", (getter)UIDrawable::get_on_exit, (setter)UIDrawable::set_on_exit, \
MCRF_PROPERTY(on_exit, \
"Callback for mouse exit events. " \
"Called with (x, y, button, action) when mouse leaves this element's bounds." \
), (void*)type_enum}, \
{"hovered", (getter)UIDrawable::get_hovered, NULL, \
MCRF_PROPERTY(hovered, \
"Whether mouse is currently over this element (read-only). " \
"Updated automatically by the engine during mouse movement." \
), (void*)type_enum}, \
{"on_move", (getter)UIDrawable::get_on_move, (setter)UIDrawable::set_on_move, \
MCRF_PROPERTY(on_move, \
"Callback for mouse movement within bounds. " \
"Called with (x, y, button, action) for each mouse movement while inside. " \
"Performance note: Called frequently during movement - keep handlers fast." \
), (void*)type_enum}
// UIEntity specializations are defined in UIEntity.cpp after UIEntity class is complete