views:

106

answers:

1

Hi,

I'm writing a class that implements a piano keyboard. Right now it's just a UIView and each key is a UIButton. I'd like the user to be able to drag their finger and hit several keys, but right now it only registers touch down. I've added UIControlEventTouchDragEnter as a way to trigger the key event but it only works if you hit a key, drag your finger elsewhere, and drag it back to the same key.

Is there a way to detect drag events with UIButtons? Will I have to start over and use something else for each key? I don't want to calculate which key the touch is on based on its coordinates because that seems like it should be unnecessary. What do you think is the simplest way to do this?

Thanks,

Luke

+1  A: 

You can track UIControlEventTouchUpOutside for the last pressed button, and it's handler check, to which button user moved his/her finger.

Nickolay O.
How can I check which button the user's finger moved to?
Luke
For example, by checking touchInside property of each button.
Nickolay O.