Re: Drag and Drop
Re: Drag and Drop
- Subject: Re: Drag and Drop
- From: Lorenzo <email@hidden>
- Date: Thu, 18 Nov 2004 15:36:15 +0100
Hi,
did you set the delegate of the outlineView?
Those methods are called by the delegate (which you could set to self or to
the instantiate object in IB);
Also, "writeItems:" has to be managed when you drag something from your
outlineView to e.g. the Finder. The other methods are to be managed when you
drag something from e.g. the Finder to your outlineView.
e.g.
- (unsigned int)outlineView:(NSOutlineView*)ftView
validateDrop:(id<NSDraggingInfo>)info
proposedItem:(id)item
proposedChildIndex:(int)childIndex
{
NSPasteboard *pboard = [info draggingPasteboard];
NSString *type = [pboard availableTypeFromArray:
[NSArray arrayWithObjects:NSStringPboardType,
NSFilenamesPboardType, nil]];
if(type && [type isEqualToString:NSFilenamesPboardType]){
NSArray *filesDragged = [pboard
propertyListForType:NSFilenamesPboardType];
if([filesDragged count] <= 0) return NSDragOperationNone;
// get here some info about the files and return
// NSDragOperationGeneric if you accept the drop
// or NSDragOperationNone if you don't accept the drop
return NSDragOperationGeneric;
}
return NSDragOperationNone;
}
Best Regards
--
Lorenzo
email: email@hidden
> Message: 3
> Date: Thu, 18 Nov 2004 17:07:41 +0900
> From: klee04 <email@hidden>
> Subject: Drag and Drop
> To: email@hidden
> Message-ID: <email@hidden>
> Content-Type: text/plain; charset="us-ascii"
>
> Hi,
>
> I found weird problem with Drag and Drop code. When I power on my Macintosh
> and run my application, drag and drop does not work. Although, mouse
> clicked event to start the drag gets called, mouse dragging event does not
> seem to get reported, and I cannot validate and accept drop. However, when
> I run some other application (any other drag and drop application), and then
> run my app, the drag and drop starts to work. This only happens when I
> reboot my computer. Does anybody know why this is happening? I do register
> my drag and drop type as shown below:
>
> [outlineView registerForDraggedTypes:[NSArray
> arrayWithObjects:NSStringPboardType, NSFilenamesPboardType, nil]];
>
> This function gets called:
>
> - (BOOL)outlineView:(NSOutlineView *)outlineView writeItems:(NSArray *)items
> toPasteboard:(NSPasteboard *)pboard
>
>
> But not these:
> - (unsigned int)outlineView:(NSOutlineView*)ftView validateDrop:(id
> <NSDraggingInfo>)info proposedItem:(id)item
> proposedChildIndex:(int)childIndex
> - (BOOL)outlineView:(NSOutlineView*)ftView acceptDrop:(id
> <NSDraggingInfo>)info item:(id)targetItem childIndex:(int)childIndex
>
>
> Any help would be greatly appreciated.
>
> Thanks.
>
> Kanghoon Lee
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden