• 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
trouble with drag and drop, NSTableview, CoreData, Document-based app
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

trouble with drag and drop, NSTableview, CoreData, Document-based app


  • Subject: trouble with drag and drop, NSTableview, CoreData, Document-based app
  • From: Dan Donaldson <email@hidden>
  • Date: Thu, 7 Sep 2006 22:21:06 -0400

I've been having problems implementing Drag and Drop in an outline view in a Core Data Document based application

I've used the example at http://allusions.sourceforge.net/articles/ treeDragPart1.php and the followup part 2 as a basis.

My assumption is that the MyDocument class will take on the role of managing dragging inside the table. On awakeFromNib, I register the table for drag and drop thus:

- (void)awakeFromNib {	

dragType = [NSArray arrayWithObjects:@"myDragType", nil];
[ dragType retain ];
[ treeTable registerForDraggedTypes:dragType ];
NSLog(@"registered");
NSSortDescriptor* sortDesc = [[NSSortDescriptor alloc] initWithKey:@"position" ascending:YES];
[groupTreeControl setSortDescriptors:[NSArray arrayWithObject: sortDesc]];
[ sortDesc release ];
}


and the log message "registered" displays.

I can create objects in the outline (which uses a tree controller referencing an array controller), but when I attempt to drag an item displayed, nothing happens. I have implemented these methods:

- (BOOL) outlineView : (NSOutlineView *) outlineView
				writeItems : (NSArray*) items
				toPasteboard : (NSPasteboard*) pboard {
	NSLog(@"writeItems");
	[ pboard declareTypes:dragType owner:self ];
	draggedNode = [ items objectAtIndex:0 ];
	return YES;
}

and

- (NSDragOperation)outlineView:(NSOutlineView *)outlineView
				validateDrop:(id <NSDraggingInfo>)info
				proposedItem:(id)item
				proposedChildIndex:(int)index {

	return  YES;
}

and


- (BOOL)outlineView:(NSOutlineView *)outlineView acceptDrop:(id <NSDraggingInfo>)info item:(id)item childIndex:(int)index {

	_NSArrayControllerTreeNode* parentNode = item;
	_NSArrayControllerTreeNode* siblingNode;
	_NSControllerTreeProxy* proxy = [ groupTreeControl arrangedObjects ];
	NSManagedObject* draggedGroup = [ draggedNode observedObject ];
	NSLog(@"about to drop!");
	return YES;
}

The log messages in these methods are never seen, so presumably the methods are not being called.

Any ideas? I'm quite surprised at the state of underdocumentation and the use of undocumented methods per this example: if drag and drop isn't supported properly using this combination of useful techniques, Apple is putting a big block in the way of developers....

Dan Donaldson
416 604 3398
email@hidden



_______________________________________________
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


  • Follow-Ups:
    • Re: trouble with drag and drop, NSTableview, CoreData, Document-based app
      • From: George Orthwein <email@hidden>
  • Prev by Date: Re: Checking for an internet connection
  • Next by Date: Re: Re: Checking for an internet connection
  • Previous by thread: Re: Re: Checking for an internet connection
  • Next by thread: Re: trouble with drag and drop, NSTableview, CoreData, Document-based app
  • Index(es):
    • Date
    • Thread