rmq icon indicating copy to clipboard operation
rmq copied to clipboard

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

Open HealsCodes opened this issue 9 years ago • 5 comments

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" }

HealsCodes avatar Aug 24 '15 14:08 HealsCodes

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.

twerth avatar Aug 24 '15 15:08 twerth

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 :wink:)

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.

HealsCodes avatar Aug 24 '15 15:08 HealsCodes

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.

twerth avatar Aug 24 '15 15:08 twerth

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.

GantMan avatar Aug 24 '15 16:08 GantMan

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.

jamonholmgren avatar Aug 25 '15 18:08 jamonholmgren