Skip to content

Add UIInteractiveSpriteWidget for clickable sprites in UI#2849

Open
pvcraven wants to merge 3 commits intodevelopmentfrom
feature/interactive-sprite-widget
Open

Add UIInteractiveSpriteWidget for clickable sprites in UI#2849
pvcraven wants to merge 3 commits intodevelopmentfrom
feature/interactive-sprite-widget

Conversation

@pvcraven
Copy link
Copy Markdown
Member

@pvcraven pvcraven commented May 7, 2026

Summary

  • Adds UIInteractiveSpriteWidget — combines UIInteractiveWidget + UISpriteWidget via multiple inheritance to make sprites clickable/hoverable in the UI tree
  • Widget size defaults to sprite texture dimensions, overridable with explicit width/height
  • Inherits full interactive behavior: hovered, pressed, disabled states, on_click event dispatch, keyboard/controller support
  • Inherits sprite rendering: do_render() draws the sprite, on_update() calls sprite animation updates
  • Exported from arcade.gui as public API

Test plan

  • Click on sprite fires on_click event with correct source
  • Click outside does not fire
  • hovered updates on mouse enter/leave
  • pressed is True between press and release
  • disabled=True blocks click events
  • Widget rect defaults to sprite texture size
  • Explicit width/height overrides sprite size
  • Works inside UIBoxLayout and UIAnchorLayout
  • Callback via push_handlers(on_click=...) works
  • Callback via widget.on_click = callback works
  • All 349 existing GUI tests pass

🤖 Generated with Claude Code

Paul V Craven and others added 3 commits May 7, 2026 13:03
Combines UIInteractiveWidget and UISpriteWidget via multiple
inheritance, giving sprites full UI event dispatch: hover detection,
press tracking, click events, and disabled state — without
requiring manual hit testing or state management.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- Introduced UIInteractiveSpriteWidget for clickable sprites in the UI.
- Added example code demonstrating sprite interaction with hover and click feedback.
- Updated documentation to include the new interactive sprite widget and its usage.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant