• 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
Handling a File Drag to my Window
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Handling a File Drag to my Window


  • Subject: Handling a File Drag to my Window
  • From: Peter Zegelin <email@hidden>
  • Date: Wed, 23 Sep 2009 12:48:57 +1000

I want to us e the whole window of my application as the drop target for files dragged onto it from the Finder but there are a couple of things I can't seem to figure out:

I would like to show some sort of visual feedback. I tried subclassing the content view of the window thinking it would automatically hilite, but I can't get it to. Note I set focus ring to default in IB for this. Also the drag icon doesn't update to show a '+' symbol.

After I get the file what should I do to make sure the document is still set up correctly. I currently call my documents readFromURL: ofType: error: method to load the file but I am not sure if that is correct as calling
synchronizeWindowTitleWithDocumentName afterwards doesn't change the title of the window to the new file name.


Note that I would like to reuse the document and window, not create a new one. This is what I am currently doing inside my NSWindowController subclass:

- (void)awakeFromNib{

[[self window] registerForDraggedTypes:[NSArray arrayWithObjects:NSURLPboardType, nil]];
}




- (NSDragOperation)draggingEntered:(id <NSDraggingInfo>)sender {

	return NSDragOperationGeneric;
}


- (BOOL)performDragOperation:(id <NSDraggingInfo>)sender{
NSPasteboard *pboard = [sender draggingPasteboard];


if ( not [[pboard types] containsObject:NSURLPboardType] )
return NO;

if( not [[self document] readFromURL:[NSURL URLFromPasteboard:pboard] ofType:@"AVR Hex File" error:nil])
return NO;

[self synchronizeWindowTitleWithDocumentName];

return YES;
}



thanks for any help!

Peter
_______________________________________________

Cocoa-dev mailing list (email@hidden)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden


  • Follow-Ups:
    • Re: Handling a File Drag to my Window
      • From: Peter Zegelin <email@hidden>
    • Re: Handling a File Drag to my Window
      • From: Graham Cox <email@hidden>
    • Re: Handling a File Drag to my Window
      • From: Rob Keniger <email@hidden>
  • Prev by Date: Re: Stability on Snow Leopard
  • Next by Date: Re: an app that never quits
  • Previous by thread: Re: Stability on Snow Leopard
  • Next by thread: Re: Handling a File Drag to my Window
  • Index(es):
    • Date
    • Thread