• 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
mouse pointer for drag copy
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

mouse pointer for drag copy


  • Subject: mouse pointer for drag copy
  • From: Adam Maxwell <email@hidden>
  • Date: Thu, 29 Jul 2004 12:11:14 -0500

I'm using promise drags to copy files from a table view to the Finder, based on code I found from the archives of this list. Things are working fine, but I don't see the mouse pointer change to the green circle with a plus sign that typically indicates a drag copy in the Finder and elsewhere. Do I have to do something special to get this?

For completeness' sake, here is the code I use to set up the drag in my table view delegate:

- (BOOL)tableView:(NSTableView *)tv writeRows:(NSArray *)rows toPasteboard:(NSPasteboard *)pboard{
NSEnumerator *e = [rows objectEnumerator];
NSNumber *row;
NSMutableDictionary *dict = [NSMutableDictionary dictionaryWithCapacity:2];

// set up the dragged image stuff
NSPoint dragPosition = [tv convertPoint:[window convertScreenToBase:[NSEvent mouseLocation]] fromView:nil];
NSRect imageLocation;
dragPosition.x -= 16;
dragPosition.y -= 16;
imageLocation.origin = dragPosition;
imageLocation.size = NSMakeSize(32,32);

// we want the drag to occur for the row that is clicked, not the row that is selected
if(![tv isRowSelected:[tv rowAtPoint:dragPosition]]){
[tv selectRow:[tv rowAtPoint:dragPosition] byExtendingSelection:NO];
}

// set up the pasteboard for the promise drag
[pboard declareTypes:[NSArray arrayWithObject:NSFilesPromisePboardType] owner:nil];
[pboard setPropertyList:[self namesOfSelectedFiles] forType:NSFilesPromisePboardType];

// this array (private ivar) stores the new and old path of all the files we are dragging
[BR_dragDictArray removeAllObjects];

while(row = [e nextObject]){
if([[theFileHandler newPathAtIndex:row] isEqualToString:@""]){// check to see if we've renamed/previewed yet
return NO; // return NO to avoid hanging the drag receiver
} else {
[dict setObject:[theFileHandler oldPathAtIndex:row] forKey:@"old"];
[dict setObject:[theFileHandler newPathAtIndex:row] forKey:@"new"];
[BR_dragDictArray addObject:[dict copy]];
[dict removeAllObjects];
}
}


[tv dragPromisedFilesOfTypes:[NSArray arrayWithObject:@""]
fromRect:imageLocation
source:tv
slideBack:YES
event:[NSApp currentEvent]];

return NO;
}
_______________________________________________
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.


  • Follow-Ups:
    • Re: mouse pointer for drag copy
      • From: Adam Maxwell <email@hidden>
    • Re: mouse pointer for drag copy
      • From: Nick Zitzmann <email@hidden>
    • Re: mouse pointer for drag copy
      • From: Allan Odgaard <email@hidden>
  • Prev by Date: NSTableView, bindings, auto-sorting
  • Next by Date: Re: mouse pointer for drag copy
  • Previous by thread: NSTableView, bindings, auto-sorting
  • Next by thread: Re: mouse pointer for drag copy
  • Index(es):
    • Date
    • Thread