UIButton bounds - drag exit location is way outside the drawn button

Discussion in 'iOS Programming' started by 99miles, Oct 10, 2008.

  1. 99miles macrumors member

    Joined:
    Oct 10, 2008
    #1
    If I just drag a button into a window in Interface Builder, then run the app, when I click on the button and drag out of the button it doesn't become un-highlighted until I'm way outside the button. So, the dragExit and dragEnter events aren't getting fired on the borders of the drawn button. Why is that, and how can I fix it? I've played with frame and bounds but still can't seem to get it working as i'd expect.
    Thanks.
     
  2. PhoneyDeveloper macrumors 68030

    PhoneyDeveloper

    Joined:
    Sep 2, 2008
    #2
    That's the way it is. It's because people have fat fingers. It's a more reliable way for people to get the phone to respond to their touches.
     
  3. 99miles thread starter macrumors member

    Joined:
    Oct 10, 2008
    #3
    Thanks for the reply.

    So, how would I do the following...

    I want two button next to each other. I want to touch one, then drag out and onto the other so that I can have them both in a selected state. I know I need to override the events, but how can I track the dragEnter on the second button if the dragExit event hasn't yet fired from the first one? Does that make sense?
     
  4. PhoneyDeveloper macrumors 68030

    PhoneyDeveloper

    Joined:
    Sep 2, 2008
    #4
    Are these just regular buttons? If so that's kind of an odd scenario.

    The only way I can think of is to do the touch tracking higher up the responder chain. You need to have an enclosing view that tracks the touches and highlights and un-highlights the buttons based on your logic. Either an enclosing view or a view controller can do this. I think you'd have to turn off userInteractionEnabled for the buttons so the touches would be passed up the responder chain.

    It might also be possible to subclass UIButton and override the touches callbacks and do your own touch tracking and not pass the events to the base class.
     
  5. 99miles thread starter macrumors member

    Joined:
    Oct 10, 2008
    #5
    Thank you so much, you got me on the right track!
     
  6. ankurj macrumors newbie

    Joined:
    Jun 27, 2011
    #6
    question on the same thing.

    Do you mind sharing the snippet on how you were able to achieve this. If I make UserInteractionEnabled to false then I don't get any events on the button.

    Alternatively I am able to track the drag out even from one button, but when then finger goes on to the second button the drag in event is not getting fired. I believe that is due to the fact that I need to pass on the event to the responder chain.

    But I don't know how to pass the event back to say UI Window or the parent view. Can you please give some guidance in that.
     

Share This Page