Strange NSTableView drag and drop error - MacRumors Forums
Register FAQ / Rules Forum Spy Search Today's Posts Mark Forums Read
Go Back   MacRumors Forums > Apple Systems and Services > Programming > Mac Programming

Reply
 
Thread Tools Search this Thread Display Modes
Old Sep 21, 2004, 09:45 PM   #1
HexMonkey
Administrator
 
HexMonkey's Avatar
 
Join Date: Feb 2004
Location: New Zealand
Strange NSTableView drag and drop error

I have an NSTableView in my Cocoa application that accepts files dragged from Finder. It works fine, except when it has no items in it and the mouse goes over the top row of pixels of the NSTableView's content area while dragging (see the attached picture if this isn't clear, the red line is the area affected). When this happens, I get an error printed to the run log/console:

ERROR: Attempt to set dropRow=0, dropOperation=NSTableViewDropOn when [0 - 0] is valid range of rows.

Thinking it was a bug somewhere in my code, I created a new project with only the necessary code, and it still occured. The steps taken to create the project were:
  1. Create a new Cocoa application in Xcode
  2. Put an NSTableView in the main window of MainMenu.nib
  3. Create a class called "Controller" and create an outlet for the NSTableView called "tableView"
  4. Instantiate Controller
  5. Set Controller as the NSTableView's dataSource and set the NSTableView to Controller's tableView outlet.
  6. Create the files for Controller
  7. Use the code below for Controller.m

Code:
#import "Controller.h"

@implementation Controller

-(NSDragOperation)tableView:(NSTableView *)tv validateDrop:(id <NSDraggingInfo>)info proposedRow:(int)row proposedDropOperation:(NSTableViewDropOperation)operation
{
	NSLog(@"validateDrop");
	[tv setDropRow: -1 dropOperation: NSTableViewDropOn];
	return NSDragOperationCopy;
}

-(BOOL)tableView:(NSTableView *)tv acceptDrop:(id <NSDraggingInfo>)info row:(int)row dropOperation:(NSTableViewDropOperation)operation
{
	return YES;
}

-(void)awakeFromNib
{
	[tableView registerForDraggedTypes:[NSArray arrayWithObjects:NSFilenamesPboardType, nil]];
}

-(void)dealloc
{
	[tableView unregisterDraggedTypes];
}

@end
The output of the run log when dragging a file over the affected area was:

Quote:
2004-09-22 14:07:50.559 TableView[12982] ERROR: Attempt to set dropRow=0, dropOperation=NSTableViewDropOn when [0 - 0] is valid range of rows.
2004-09-22 14:07:50.559 TableView[12982] ERROR: Attempt to set dropRow=0, dropOperation=NSTableViewDropOn when [0 - 0] is valid range of rows.
2004-09-22 14:07:50.560 TableView[12982] validateDrop
Since the errors occured before "validateDrop" was printed, this shows that the bug occured before validateDrop is run.

I'm using Mac OS X 10.3.4 and Xcode 1.5.

Obviously this isn't a huge bug, but does anyone know of a solution, or is this unpreventable?
Attached Images
 
HexMonkey is offline   0 Reply With Quote
Old Sep 24, 2004, 03:11 AM   #2
iMeowbot
macrumors 601
 
iMeowbot's Avatar
 
Join Date: Aug 2003
Huh. For what it's worth, I can duplicate it, and it doesn't matter what validateDrop does or returns. It really looks like some internal debugging cruft that Apple left behind.
iMeowbot is offline   0 Reply With Quote

Reply
MacRumors Forums > Apple Systems and Services > Programming > Mac Programming

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Similar Threads
thread Thread Starter Forum Replies Last Post
[Mac App Store] Introducing Yoink - take the drag out of drag and drop m.gansrigler Mac Applications and Mac App Store 25 May 19, 2014 06:35 AM
drag and drop to toolbar mikecwest OS X Mavericks (10.9) 0 Aug 14, 2013 12:07 AM
Drag and drop tutorial? scrub0bk iPhone/iPad Programming 1 May 6, 2013 08:19 AM
iTunes 11 Drag and drop gone? xSinghx Mac Applications and Mac App Store 8 Dec 8, 2012 06:54 AM
Drag and Drop on a TableView, NSDraggingInfo error BadWolf13 Mac Programming 1 Nov 6, 2012 07:10 PM

Forum Jump

All times are GMT -5. The time now is 02:25 AM.

Mac Rumors | Mac | iPhone | iPhone Game Reviews | iPhone Apps

Mobile Version | Fixed | Fluid | Fluid HD
Copyright 2002-2013, MacRumors.com, LLC