Open
Conversation
GameWidget previously blocked all pointer events from reaching Flutter widgets behind it, even when transparent and without input handling. - Replace ColoredBox with DecoratedBox to avoid opaque hit testing - Set MouseRegion opaque to false since it only tracks cursor changes - Change RawGestureDetector to HitTestBehavior.deferToChild so it only intercepts events when a game component reports a hit - Add GameRenderBox.hitTestSelf that delegates to Game - Add Game.containsEventHandlerAt with FlameGame override that checks componentsAtPoint for event callback mixins (TapCallbacks, etc.) Events now pass through empty game space to widgets behind the GameWidget, while still being intercepted by game components that have event handling mixins.
…ivery The hit test in containsEventHandlerAt now caches the full tree traversal so the immediate event delivery can replay it, reducing redundant componentsAtPoint calls from 3 to 2 per tap.
…ivery The hit test in containsEventHandlerAt now caches the full tree traversal so the immediate event delivery can replay it, reducing redundant componentsAtPoint calls from 3 to 2 per tap. Uses a position-keyed map to support concurrent multitouch correctly. # Conflicts: # packages/flame/lib/src/game/flame_game.dart
Benchmarking showed the cache added complexity without measurable performance benefit. containsEventHandlerAt now simply uses super.componentsAtPoint to check for event handlers at a position.
Adds HitTestBehavior parameter (default opaque) so users can opt into event passthrough with deferToChild or translucent. Includes tests for all three behaviors.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
This adds the ability for Flutter widgets to receive events when they are underneath a
GameWidget, for example in aStack.Checklist
docsand added dartdoc comments with///.examplesordocs.Breaking Change?
Related Issues