• 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
Re: Drag and drop promised files to Finder
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Drag and drop promised files to Finder


  • Subject: Re: Drag and drop promised files to Finder
  • From: Renaud Boisjoly <email@hidden>
  • Date: Wed, 20 Aug 2003 08:03:43 -0400

Thanks Tim! This will be really valuable in figuring it out. But I will
file a bug with Apple too.

- Renaud

On Wednesday, Aug 20, 2003, at 05:02 America/Montreal, Tim Hewett wrote:

>> Message: 10
>> Date: Tue, 19 Aug 2003 18:51:24 -0700
>> Subject: Re: Drag and drop promised files to Finder
>> Cc: email@hidden
>> To: Renaud Boisjoly <email@hidden>
>> From: Nick Zitzmann <email@hidden>
>>
>> On Tuesday, August 19, 2003, at 06:00 PM, Renaud Boisjoly wrote:
>>
>>> Buy, this is not as simple as it should be...
>>>
>>> Any sample code out there I could look at?
>>
>> Please join several of us here in filing bug reports on this issue. As
>> things stand right now, doing file promise DnD with either NSTableView
>> or NSOutlineView is very difficult to implement correctly, and more or
>> less impossible to implement flawlessly.
>>
>> I got it to "work" once by adding the -dragPromisedFilesOfTypes:...
>> call in the NSTableView -tableView:writeRows:toPasteboard: data source
>> method. But if this call returns NO, then the Objective-C message
>> queue
>> eventually freezes, and if it returns YES, then the application
>> eventually crashes. The former can be worked around by clicking once
>> in
>> the application, but I wish it just worked.
>>
>> Nick Zitzmann
>> AIM/iChat: dragonsdontsleep
>> Check out my software page: http://seiryu.home.comcast.net/
>
> Renaud,
>
> The code below is what I have working reliably in the subclass of a
> NSTableView, it will possibly be useful for your NSOutlineView too.
> I really have no problem with it except for the fact that it was hard
> to
> get it working in the first place.
>
> See it for yourself, you can download the evaluation version of the
> software at coolatoola.com - create a backup then drag it to the Finder
> to exercise the code.
>
> Regards,
>
> Tim.
>
> - (void)mouseDown:(NSEvent *)theEvent
> {
> NSPoint dragPosition;
> NSRect imageLocation;
> int column;
>
>
> //
> // We need to check that promised files are supported - they are
> not in pre-10.2 OSs.
> //
> if ( [self
> respondsToSelector:@selector(dragPromisedFilesOfTypes:fromRect:source:s
> lideBack:event:)] == NO ) {
>
> NSLog( @"Promised file drag-and-drop is not supported." );
> [super mouseDown:theEvent];
> return;
> }
>
> dragPosition = [self convertPoint:[theEvent locationInWindow]
> fromView:nil];
> restoreDragRow = [self rowAtPoint:dragPosition];
> column = [self columnAtPoint:dragPosition];
>
> [self selectRow:restoreDragRow byExtendingSelection:NO];
>
> [NSEvent startPeriodicEventsAfterDelay:0.3 withPeriod:0];
> NSEvent *newEvent = [[self window]
> nextEventMatchingMask:NSLeftMouseUpMask | NSLeftMouseDraggedMask];
>
> switch ( [newEvent type] ) {
>
> case NSLeftMouseUp:
>
> [NSEvent stopPeriodicEvents];
>
> break;
>
> case NSLeftMouseDragged:
>
> [NSEvent stopPeriodicEvents];
>
> if ( (restoreDragRow != -1) && (restoreDragRow < /* "Number of rows
> in table" */ ) ) {
>
> dragPosition.x -= 28;
> dragPosition.y -= 10;
> imageLocation.origin = dragPosition;
> imageLocation.size = NSMakeSize( 16, 16 );
>
> NSString *extension = [[[self delegate]
> getOriginalPath:restoreDragRow] pathExtension];
>
> if ( ![extension length] || ([extension length] > 4) )
> extension = @"'docs'";
>
> [self dragPromisedFilesOfTypes:[NSArray arrayWithObject:extension]
> fromRect:imageLocation source:self slideBack:YES event:theEvent];
> }
>
> break;
>
> default:
> break;
> }
> }
>
> - (NSArray *)namesOfPromisedFilesDroppedAtDestination:(NSURL *)url
> {
> printf( "Dropped to: %s\n", [[url path] cString] );
>
> // Get the finder path out of the URL here;
>
> return nil;
> }
>
> - (NSDragOperation)draggingSourceOperationMaskForLocal:(BOOL)isLocal {
>
> if (isLocal) return NSDragOperationNone;
> else return NSDragOperationCopy;
> }
>
> - (BOOL)shouldDelayWindowOrderingForEvent:(NSEvent *)theEvent
> {
> return YES;
> }
>
> - (BOOL)acceptsFirstMouse:(NSEvent *)theEvent
> {
> return YES;
> }
_______________________________________________
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.

References: 
 >Re: Drag and drop promised files to Finder (From: Tim Hewett <email@hidden>)

  • Prev by Date: Re: NSSplitView can't expand once collapsed
  • Next by Date: Re: popupbuttons
  • Previous by thread: Re: Drag and drop promised files to Finder
  • Next by thread: Re: Drag and drop promised files to Finder
  • Index(es):
    • Date
    • Thread