Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for multiple gestures of the same type with different parameters #295

Open
HealsCodes opened this issue Aug 24, 2015 · 5 comments

Comments

@HealsCodes
Copy link
Contributor

I'm having a hard time adding two separate :tap gestures to my view.
The goal is to trigger different actions if the view was tapped with one or two fingers.
I know in pure Cocoa-Touch this is possible by adding different recognizers and making use of requestRecognizerToFail() to differentiate.

I think there should be a way in RMQ to do this:

rmq.on(:tap, fingers_required: 1) { |sender, event| puts "one finger tap" }
rmq.on(:tap, fingers_required: 2, taps_required: 2) { |sender, event| puts "two finger double tap" }
@twerth
Copy link
Member

twerth commented Aug 24, 2015

Hi Shirk, we've considered this before, but it makes the system way more complicated, we ended up doing somethign like this instead:

rmq.on(:two_finger_tap)

^ This doesn't exist, but that's how we handed sliding and such. Hmm I'll have to think about it.

@HealsCodes
Copy link
Contributor Author

I understand your reasoning and I can relate to it.
But it would've been nice to be able to use RMQ for all my gesture handling
(instead of mixing or falling back to native iOS methods 😉)

I'm a great fan of RMQ and as an extend of it Redpotion and I have hopes that I can minimize porting
if I should ever get to targeting iOS and Android (using Red- and Bluepotion).
That would be much, much easier if I wouldn't have to use os specific methods.

@twerth
Copy link
Member

twerth commented Aug 24, 2015

FYI, BluePotion/Android works the same way (although it's super minimal at this point). Another good reason to keep events as simple as possible.

@GantMan
Copy link
Member

GantMan commented Aug 24, 2015

I kind of like a mix of what the two of you are saying.

for single gestures, do rmq.on(:tap),

For an array of gesture possibilities create a second class to hold the complexity. rmq.on(:advanced_taps), and here is where you can add complexity of multiple events etc. This keeps the framework the same, and silos the other tap needs (however many there may be) in an advanced object most people can ignore until they need it, too.

@jamonholmgren
Copy link
Member

Note that Sugarcube does support what @Shirk is asking for.

view.on_tap(taps: 1, fingers: 1) do |sender|
  # ...
end

I think we could support it here too. I agree with @Shirk that this is a much nicer way to define it.

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

No branches or pull requests

4 participants