RE: NSOutlineView validateDrop Flips Values
RE: NSOutlineView validateDrop Flips Values
- Subject: RE: NSOutlineView validateDrop Flips Values
- From: "Paulo F. Andrade" <email@hidden>
- Date: Tue, 3 Jul 2007 19:52:10 +0100
I'm having exactly the same problem! Have you solved this??
Thanks,
Paulo F. Andrade 52439@IST
mailto: email@hidden
I'm attempting to add drag and drop support to an outline view in
my app (proving to be more difficult than I thought it would be)
and I came across a weird behavior. If I drag an item and hold it
on top of an item in the list, the proposedItem parameter to
validateDrop:proposedItem:proposedChildIndex: flips between an
appropriate value and nil every other time the message is sent.
This is without moving the mouse or anything. It simply changes on
it's own and I'm not sure why.
Hopefully this is easy enough to understand:
- (NSDragOperation)outlineView:(NSOutlineView*)olv validateDrop:(id
<NSDraggingInfo>)info proposedItem:(id)item proposedChildIndex:(int)
childIndex
{
// This method validates whether or not the proposal is a valid
one. Returns NO if the drop should not be allowed.
id <FileSystemItem> targetNode = item;
BOOL targetNodeIsValid = YES;
BOOL isOnDropTypeProposal = (childIndex ==
NSOutlineViewDropOnItemIndex);
if (item == nil)
NSLog(@"Item is nil");
else
NSLog(@"Item is not nil");
// Refuse if: dropping "on" the view itself unless we have no data
in the view.
if (targetNode == nil && childIndex == NSOutlineViewDropOnItemIndex
&& [[self currentDirectory] numberOfChildren] != 0)
targetNodeIsValid = NO;
if (targetNode == nil && childIndex == NSOutlineViewDropOnItemIndex
&& NO == NO) // first no is: [self allowOnDropOnLeaf]
targetNodeIsValid = NO;
// Refuse if: we are trying to do something which is not allowed as
specified by the UI check boxes.
if ((targetNodeIsValid && isOnDropTypeProposal==NO && YES == NO)
|| // Drop Between
([targetNode isDirectory] && isOnDropTypeProposal == YES && YES ==
NO) || // Drop On Group
([targetNode isDirectory] == NO && isOnDropTypeProposal == YES &&
NO == NO)) // Drop on Item
targetNodeIsValid = NO;
// Set the item and child index in case we computed a retargeted one.
[olv setDropItem:targetNode dropChildIndex:childIndex];
return targetNodeIsValid ? NSDragOperationMove : NSDragOperationNone;
}
Thanks,
-- Seth
_______________________________________________
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