Re: Drag and Drop in Same View
Re: Drag and Drop in Same View
- Subject: Re: Drag and Drop in Same View
- From: email@hidden
- Date: Sun, 19 Sep 2010 22:26:02 -0600
Word Up to Raleigh! Just added one of my type and voila!
Thanks.
-koko
[self registerForDraggedTypes:[NSArray arrayWithObjects:NSDragPboard,
@"Jump", nil]];
in -mouseDragged:
[pboard declareTypes:[NSArray arrayWithObject:@"Jump"] owner:self];
[pboard setData:[NSData data] forType:@"Jump"];
[self dragImage:img at:localPt offset:sz event:theEvent
pasteboard:pboard source:self slideBack:NO];
On Sep 19, 2010, at 9:00 PM, Raleigh Ledet wrote:
NSDragPboard is the name of a pasteboard, not the dragged type. The
drag type is the type of data you put on the pasteboard to drag. For
example, is you are dragging a URL, then register for kUTTypeURL.
If it's private data then it's along these lines:
NSString *myType =
UTTypeCreatePreferredIdentifierForTag(kUTTagClassNSPboardType,
CFSTR("privateDat", kUTTypeData); // You are using UTIs right?
-(id)init.... {
...
[self registerForDraggedTypes:[NSArray arrayWithObjects:myType, nil]];
...
}
-(void)mouseDown:(NSEvent*)event {
...
[pboard clearContents];
NSPasteboardItem *item = [[[NSPasteboardItem alloc] init]
autorelease];
[item setData:data forType:myType];
[pboard writeObjects:[NSArray arrayWithObject:item]];
// start drag
...
}
-raleigh
On Sep 19, 2010, at 7:43 PM, email@hidden wrote:
Sorry ... I did not say I had done that as follows:
[self registerForDraggedTypes:[NSArray
arrayWithObjects:NSDragPboard, nil]];
On Sep 19, 2010, at 7:19 PM, Raleigh Ledet wrote:
You need to register as a dragging destination for your dragging
type:
-registerForDraggedTypes:
http://developer.apple.com/library/mac/#documentation/Cocoa/
Reference/ApplicationKit/Classes/NSView_Class/Reference/NSView.html
#//apple_ref/occ/instm/NSView/registerForDraggedTypes:
-raleigh
On Sep 19, 2010, at 5:08 PM, email@hidden wrote:
I do
dragImage:at:offset:event:pasteboard:source:slideBack:
in a view's mouseDragged method.
The view also implements all the correct methods for dragging as
outlined in the example Erik Buck referred to. These dragging
methods are never called. So what must be done to Drop in the
view that originates the Drag?
It this possible?
-koko
_______________________________________________
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
_______________________________________________
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