UIButtons creating a native-like keyboard behavior.

Posted by camilo on Stack Overflow See other posts from Stack Overflow or by camilo
Published on 2010-06-10T15:43:11Z Indexed on 2010/06/11 15:32 UTC
Read the original article Hit count: 267

Filed under:
|
|
|
|

Greets. A somehow detailed explanation on my problem, and what I have already done, and what I cannot do.

I want to create a behavior resembling the one in the iPhone's keyboard. Basically, I want a view to appear when the user taps a button and WHILE the user taps that button.

This, I accomplished.

When the user lets go of the button WHILE his finger is on that button's area, I want to trigger an action "doing stuff".

This, I was also able to do.

Since all the buttons are near (like in the keyboard) and I don't want the user to select other button than the one he pressed, I reduced the hit area for the button using the -(BOOL)pointInside:(CGPoint)point withEvent:(UIEvent )event function.

When the user presses the button, not lifting its finger, and dragging outside the button area, I want another action to trigger. This is the first problem... This function only triggers when the user's finger is far from the buttons' area, and this time the pointInside function is not being my friend. How can I detect the user finger "left" the button area the moment it exits its bounds?

This, in case you didn't realize... was problem 1.

The second problem is related with the drag enter. Again, I need to limit the area like in the drag exit. But I suppose that when I solve one of these, the other is the same. The problem is that in order to have a behavior like in the keyboard, I may need to detect the user started the touch in another button, never lifted his finger, and changed to another button. I can detect drag enter and drag exit IN THIS ORDER while on the same button. I cannot detect drag enter when the user first touched anywhere else other than the button where I want to detect the drag enter event. Basically what I need is to detect touch on any button (and not anywhere else in the view), and while the user is changing buttons without lifting the finger, I want to detect the new button being touched.

This gigantic paragraph was problem #2.

Any help, as you might guess, is highly appreciated.

Best Regards. Thanks a lot!

© Stack Overflow or respective owner

Related posts about iphone

Related posts about objective-c