drop location
drop location
- Subject: drop location
- From: Koen van der Drift <email@hidden>
- Date: Sat, 19 Jun 2004 12:50:41 -0400
Hi,
In my app the user can drag items from a tableview to another view to
create a drawing. I used to have the tableview in a separate
palette-type window, and this all worked fine. I decided I want to have
the table in the mainview, so all controls are in the same window, and
I moved the code from the paletteWindowController to the
mainWindowController. The mainWindowController now is in charge of the
tableview as well as the drawing view. What happens is that when a new
item is dropped it ends up at a different location than where the mouse
is. Here are some snippets:
To start a drag:
- (BOOL)tableView:(NSTableView *)aTableView writeRows:(NSArray *)rows
toPasteboard:(NSPasteboard *)pboard
{
// just use lastobject - there's only one selection possible
int index = [[rows lastObject] intValue];
[pboard declareTypes: [NSArray arrayWithObject:SMPasteboardType]
owner:self];
[pboard setString: [myTableList objectAtIndex:index]
forType:SMPasteboardType];
return YES;
}
And to accept the drop:
- (BOOL)dropItem:(id <NSDraggingInfo>)sender
{
NSPasteboard *pb;
NSString *itemTag;
if ( [self validateDrag:sender] )
{
pb = [sender draggingPasteboard];
itemTag = [pb stringForType:SMPasteboardType];
[[[self document] drawing] addItemWithName: itemTag
atLocation: [sender draggingLocation]];
return YES;
}
return NO;
}
My guess is that the draggingLocation is relative to the tableview. If
that is the case, is there a way to fix this, or maybe there is another
way to get the droplocation?
thanks,
- Koen.
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.