Skip to content

feat!: Support secondary taps (right click) on new callbacks system#3741

Merged
luanpotter merged 2 commits intomainfrom
luan.secondary
Oct 6, 2025
Merged

feat!: Support secondary taps (right click) on new callbacks system#3741
luanpotter merged 2 commits intomainfrom
luan.secondary

Conversation

@luanpotter
Copy link
Copy Markdown
Member

@luanpotter luanpotter commented Oct 5, 2025

Description

Support secondary taps (right click) on new callbacks system.

In order to follow through with our event system migration, we need to make sure the new system is equipped to support all use cases; also changes the existing TapCallbacks to be primary-only.

I noticed that we don't support "secondary taps" (i.e. right clicks), so I am adding this. I honestly really dislike the fact that this is considered a completely different event from the left click, instead of just a property on the click event. But I kept this structure to replicate what Flutter does, so this is more familiar for users. I think that is worth the slight verbosity of having yet another detector. Also, it plays well this way with Flutter because that underlying events are a bit different (for example, the secondary ones don't support pointId).

Note: this is a slight breaking change because the existing detector works for BOTH left and right click, but there is NO WAY of distinguishing them because the buttons property is not propagated in the Flutter end (massive oversight I believe - might put a PR later). Since this provides the secondary as a solution, it also removes secondary clicks from triggering the primary. I think this is more versatile than having tap detector=(primary OR secondary) and secondary=(secondary only).

I don't think this should affect basically any users because (1) desktop only and (2) this acceptance of right clicks was probably a bug anyway (for example, on the example it would rotate the square and also open the context menu, which is jarring).

However I am happy to add an option or pursue a different approach, I believe this is the best path forward, IMO.

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 requested a review from a team October 5, 2025 19:11
Copy link
Copy Markdown
Member

@spydon spydon left a comment

Choose a reason for hiding this comment

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

Lgtm, just one minor comment on the example

}
}

class TappableSquare extends PositionComponent
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Why not extend RectangleComponent?

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.

this is in line with how the other tap examples do it; I can followup and update all so they are consistent

@luanpotter luanpotter enabled auto-merge (squash) October 6, 2025 13:27
@luanpotter
Copy link
Copy Markdown
Member Author

@felangel I was wondering if it was possible to add a link to the github check so we can see more details?

@felangel
Copy link
Copy Markdown
Contributor

felangel commented Oct 6, 2025

@felangel I was wondering if it was possible to add a link to the github check so we can see more details?

I’m investigating right now

@felangel
Copy link
Copy Markdown
Contributor

felangel commented Oct 6, 2025

Can you try closing and reopening the pr in the meantime?

@spydon spydon closed this Oct 6, 2025
auto-merge was automatically disabled October 6, 2025 15:05

Pull request was closed

@spydon spydon reopened this Oct 6, 2025
@luanpotter luanpotter merged commit 46bd385 into main Oct 6, 2025
70 checks passed
@luanpotter luanpotter deleted the luan.secondary branch October 6, 2025 15:11
luanpotter added a commit that referenced this pull request Oct 6, 2025
…3745)

Update input examples to use `RectangleComponent` where sensible.

Minor simplification as suggested by @spydon on
#3741
@filiph
Copy link
Copy Markdown
Contributor

filiph commented Nov 8, 2025

FWIW, I'm also using middle click in my game (once you're on desktop and using keyboard+mouse input, you want to give players as many options as possible). I'm sharing it here just as a piece of context for later. I have my own workaround (I'm getting my clicks from Listener.onPointerDown).

The good news that there are no more buttons, basically. It's (from flutter/lib/src/gestures/events.dart): kPrimaryButton, kSecondaryButton, kTertiaryButton.

nickf2k pushed a commit to nickf2k/flame that referenced this pull request Nov 16, 2025
…lame-engine#3741)

Support secondary taps (right click) on new callbacks system.

In order to follow through with our [event system
migration](https://docs.google.com/document/d/1nBUup9QCPioVwWL1zs79z1hWF882tAYfNywFMdye2Qc),
we need to make sure the new system is equipped to support all use
cases; also changes the existing TapCallbacks to be primary-only.

I noticed that we don't support "secondary taps" (i.e. right clicks), so
I am adding this. I honestly really dislike the fact that this is
considered a completely different event from the left click, instead of
just a property on the click event. But I kept this structure to
replicate what Flutter does, so this is more familiar for users. I think
that is worth the slight verbosity of having yet another detector. Also,
it plays well this way with Flutter because that underlying events are a
bit different (for example, the secondary ones don't support `pointId`).

Note: this is a slight breaking change because the existing detector
works for BOTH left and right click, but there is NO WAY of
distinguishing them because the `buttons` property is not propagated in
the Flutter end (massive oversight I believe - might put a PR later).
Since this provides the secondary as a solution, it also removes
secondary clicks from triggering the primary. I think this is more
versatile than having tap detector=`(primary OR secondary)` and
secondary=`(secondary only)`.

I don't think this should affect basically any users because (1) desktop
only and (2) this acceptance of right clicks was probably a bug anyway
(for example, on the example it would rotate the square and also open
the context menu, which is jarring).

However I am happy to add an option or pursue a different approach, I
believe this is the best path forward, IMO.
nickf2k pushed a commit to nickf2k/flame that referenced this pull request Nov 16, 2025
…lame-engine#3745)

Update input examples to use `RectangleComponent` where sensible.

Minor simplification as suggested by @spydon on
flame-engine#3741
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants