• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
draggingEntered Not Working As Expected
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

draggingEntered Not Working As Expected


  • Subject: draggingEntered Not Working As Expected
  • From: Chris Tracewell <email@hidden>
  • Date: Wed, 03 Aug 2011 12:29:14 -0700

XCode 4, 10.6 GC -- I have an IKImageBrowserView which I have implemented drag and drop for. I have set my view controller as the image browser's drag delegate, registered for pasteboard drag types in awakeFromNib and implemented DnD protocol methods like so...

-(void)awakeFromNib
	{
	[myProductImageBrowser registerForDraggedTypes: [[NSArray arrayWithObjects:@"productIndexObjectType",NSFilenamesPboardType, nil] arrayByAddingObjectsFromArray:[NSImage imagePasteboardTypes]]];
	}

-(NSDragOperation)draggingEntered:(id <NSDraggingInfo>)sender
	{
	NSLog(@"DND Entered");
	return NSDragOperationNone;
	}

-(NSDragOperation)draggingUpdated:(id <NSDraggingInfo>)sender // validate position
	{
	NSLog(@"DND Uppdated");
	if ([myProductImageBrowser dropOperation] == IKImageBrowserDropOn)
		{
		return NSDragOperationEvery;
		}

	return NSDragOperationNone;
	}

-(BOOL)performDragOperation:(id <NSDraggingInfo>)sender // Drop Occured
	{
	NSLog(@"DND Perform");
	NSArray *theFileArray = [[sender draggingPasteboard] propertyListForType:NSFilenamesPboardType];

	if ([theFileArray count] == 1)
		{
		NSImage *theImage = [[NSImage alloc] initWithContentsOfFile:[theFileArray objectAtIndex:0]];

		if (theImage)
			{
			TKProductMaster *theProductMaster = [[myProductMasterArrayController arrangedObjects] objectAtIndex:[myProductImageBrowser indexAtLocationOfDroppedItem]];
			[theProductMaster setMyImage:theImage];
			[theProductMaster setImageVersion:[theProductMaster imageVersion] + 1]; // up the version number so the image browser knows to trash onld image cache

			[myProductImageBrowser reloadData];
			return YES;
			}
		}

	return NO;
	}

QUESTION #1
I will test for the other pboard types later, but right now what is confusing me is that draggingEntered, which returns NSDragOperationNone, is not stopping anything. The logs are showing so it is getting called. I did read in the NSDraggingDestination Protocol Reference that draggingUpdated & draggingExited will still get called even if draggingEntered returns NSDragOperationNone. Okay, but when I comment out draggingUpdated the image browser still accepts drags. Why? Shouldn't it cut off dragging altogether if draggingUpdated is never called to return NSDragOperationEvery?

QUESTION #2
I do not understand the difference between prepareForDragOperation: and performDragOperation: as they both seem to be called at the same time and have access to the same sender / info. As it is, I am only implementing performDragOperation to validate the final drop and perform the final work.


--Chris_______________________________________________

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

  • Follow-Ups:
    • Re: draggingEntered Not Working As Expected
      • From: Raleigh Ledet <email@hidden>
  • Prev by Date: Re: NSSegmentedControl
  • Next by Date: Re: NSSegmentedControl
  • Previous by thread: [RESOLVED] NSSegmentedControl
  • Next by thread: Re: draggingEntered Not Working As Expected
  • Index(es):
    • Date
    • Thread