Re: Draggable buttons
Re: Draggable buttons
- Subject: Re: Draggable buttons
- From: Serge Meynard <email@hidden>
- Date: Sat, 02 Feb 2002 21:27:42 -0500
on 2/2/02 8:19 PM, Matt Neuburg at email@hidden wrote:
>
On Sat, 2 Feb 2002 12:52:15 -0500, Ben Chess <email@hidden> said:
>
>
> The only way to start a non-TableView drag that I know of is
>
> dragImage:at:offset:event:pasteboard:source:slideBack. The docs state
>
> clearly that this is to only be called from a mouseDown event. Throwing
>
> caution into the wind, I tried saving the mouseDown event and then not
>
> making a call to dragImage until a move occurs, but it doesn't work
>
> correctly. It seems to be capturing mouse movements, but the image
>
> dragged is never drawn.
>
>
>
> I'm doing something like this in an NSResponder subclass:
>
> -(void)mouseDown:(NSEvent *)theEvent
>
> -(void)mouseMoved:(NSEvent *)theEvent
>
>
In a similar situation recently I found the example in the docs
>
(HandlingMouseEvents.html) very helpful. Basically you just run your own
>
event loop inside the mouseDown event and see what develops. m.
The book "Cocoa programming for MacOS X" has a great example in chapter 18.
Get it if you don't have it, it's definitely worth it!
Based on what you said in your message, I think the problem is you
implemented your "dragImage:" call in "mouseMoved:", when it should actually
be in "mouseDragged:". "mouseMoved:" gets called to track the pointer when
the mouse button is up, and "mouseDragged:" when it is down.
Serge