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:
The output of the run log when dragging a file over the affected area was:
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?
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:
- Create a new Cocoa application in Xcode
- Put an NSTableView in the main window of MainMenu.nib
- Create a class called "Controller" and create an outlet for the NSTableView called "tableView"
- Instantiate Controller
- Set Controller as the NSTableView's dataSource and set the NSTableView to Controller's tableView outlet.
- Create the files for Controller
- 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?