Re: Drag an drop in a custom NSView
Re: Drag an drop in a custom NSView
- Subject: Re: Drag an drop in a custom NSView
- From: Development <email@hidden>
- Date: Tue, 9 Oct 2007 18:17:24 -0700
All right, I suppose that my question was poorly asked, mostly
because as near as I can tell I don't know what to ask. I'm still
struggling with that part.
However, with the information from the responses I have gotten I have
made number of changes to the code in question. It will require many
more. BUT I have managed to get it to drag if I use the mouseDown:
method in the subclass. The problem is, I don't want it to start with
a simple mouse down.
Here is the code as I am attempting to use it: (This is within my
NSView subclass)
- (void)mouseDragged:(NSEvent *)theEvent
{
NSLog(@"Dragged");
NSPasteboard *pBoard = [NSPasteboard pasteboardWithName:NSDragPboard];
[pBoard declareTypes:[NSArray arrayWithObject:NSTIFFPboardType]
owner:self];
[pBoard setData:[imageToThumb TIFFRepresentation]
forType:NSTIFFPboardType];
NSSize offset = NSMakeSize(0.0,0.0);
NSRect location = [self frame];
[self dragImage:imageToThumb at:[self bounds].origin
offset:offset event:theEvent pasteboard:pBoard
source:self slideBack:YES];
}
This code does not work. Nothing happens when I click on the item and
drag. If i change it to mouseDown: then it works. But I don't want
that to be the case. When this problem is solved I will implement
code to have the view perform a predefined function when it is
clicked like a button. (Should I just make a subclass of NSButton for
this instead?)
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden