Skip to content

feat: Implement TertiaryTapCallbacks on new event system#3899

Open
luanpotter wants to merge 1 commit intomainfrom
luan.tertiary
Open

feat: Implement TertiaryTapCallbacks on new event system#3899
luanpotter wants to merge 1 commit intomainfrom
luan.tertiary

Conversation

@luanpotter
Copy link
Copy Markdown
Member

@luanpotter luanpotter commented Apr 12, 2026

Description

Following up on our events master plan.

This adds TertiaryTapCallbacks and necessary infrastructure to make it work.

This replaces the old TertiaryTapDetector (which we can deprecate later), e.g.:

class MyGame extends FlameGame with TertiaryTapDetector {
  @override
  void onTertiaryTapDown(TapDownInfo info) {
    // game-level handling
  }
}

With TertiaryTapCallbacks following the newer patterns in flame:

class MiddleClickSquare extends RectangleComponent with TertiaryTapCallbacks {
  @override
  void onTertiaryTapDown(TertiaryTapDownEvent event) {
    // component-level handling, with hit detection
  }

  @override
  void onTertiaryTapUp(TertiaryTapUpEvent event) {
    // tertiary tap finished
  }
}

Note that this new detector uses the same dispatcher as secondary, as they share the same underlying flutter recognizer. This is in line with my refactor on #3900 - basically we allow for multiple callbacks to register the same detector, handling deduplication and bindings.

Also adds example, tests, and documentation.

Checklist

  • I have followed the Contributor Guide when preparing my PR.
  • I have updated/added tests for ALL new/updated/fixed functionality.
  • I have updated/added relevant documentation in docs and added dartdoc comments with ///.
  • I have updated/added relevant examples in examples or docs.

Breaking Change?

  • Yes, this PR is a breaking change.
  • No, this PR is not a breaking change.

@luanpotter luanpotter force-pushed the luan.tertiary branch 2 times, most recently from 007a76c to 72bda77 Compare May 1, 2026 02:38
@@ -21,29 +21,53 @@ class SecondaryTapDispatcherKey implements ComponentKey {
/// automatically whenever any [SecondaryTapCallbacks] are mounted into the
/// component tree.
class SecondaryTapDispatcher extends Dispatcher<FlameGame> {
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

NOTE: on my consideration around whether to rename this

while it is public, it is not really user facing - I think renaming is totally fine
problem is that it is hard to name because flutter splits primary taps as a completely different recognizer
that means we have (currently) MultiTapDispatcher (for primary)
and this for secondary + tertiary
NonPrimaryTapDispatcher is the best I came up with but isn't perfect

thoughts?

@luanpotter luanpotter marked this pull request as ready for review May 1, 2026 02:54
@luanpotter luanpotter requested a review from a team May 1, 2026 02:54
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