Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

HexMonkey

Administrator emeritus
Original poster
Feb 5, 2004
2,240
504
New Zealand
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:

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?
 

Attachments

  • drag.jpg
    drag.jpg
    5.1 KB · Views: 637

iMeowbot

macrumors G3
Aug 30, 2003
8,634
0
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.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.