• 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: How to implement an open dialog in a sheet and process its output?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: How to implement an open dialog in a sheet and process its output?


  • Subject: Re: How to implement an open dialog in a sheet and process its output?
  • From: Nathaniel Gottlieb-Graham <email@hidden>
  • Date: Mon, 12 Nov 2007 14:30:24 -0500

Thanks Ron, that was a great help. I now have the following code in the .m file, but nothing happens when the button I've wired up to this is clicked on. I know the method is getting called, but the sheet never appears.


- (IBAction)askForQuickTimeMovieSheet:(id)sender {

NSOpenPanel *panel = [NSOpenPanel openPanel];
NSArray *fileTypes = [NSArray arrayWithObjects:@"mov", @"mp4", @"avi", nil];

[panel beginSheetForDirectory:@"~Movies/"
file:nil
types:fileTypes
modalForWindow:[welcomeWindow window]
modalDelegate:self
didEndSelector:@selector(filePanelDidEnd:
returnCode:
contextInfo:)
contextInfo:nil];
}


-(void)filePanelDidEnd:(NSOpenPanel*)sheet
            returnCode:(int)returnCode
           contextInfo:(void*)contextInfo {
	// Do stuff here as soon as the sheet displays properly
}

Thanks again,
Nathaniel


Hi Nathaniel,

you're right, it is easy.

First step, look at the documentation for NSOpenPanel. You'll see the instance method beginSheetForDirectory:file:types:modalForWindow:modalDelegate:didEndSelector:contextInfo :. Because it's an instance method, you first create an instance of NSOpenPanel using the class method + (NSOpenPanel *)openPanel, which, as the documentation states, creates and returns an NSOpenPanel instance. For example,

	NSOpenPanel *myOpenPanel = [NSOpenPanel openPanel];

So now configure your open panel however you like. Look at the documentation to find out how.

Then, note the instance method -filenames. Using what you get in the filenames NSArray, feed your QTMovieView with whatever it needs to play the movie.


If you need more of an explanation, read the topics referenced at the top of the NSOpenPanel Class reference document, namely, "Application File Management" and "Sheet Programming Topics for Cocoa". The second one is probably what you want to read.



Hope this helps,

Ron

PS. If you don't already have it, I'd recommend Aaron Hillegass' excellent "Cocoa Programming For Mac OS X" book.


---------------------------------
Nathaniel Gottlieb-Graham
Mac specialist
email@hidden
techpaladin.com

_______________________________________________

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: How to implement an open dialog in a sheet and process its output?
      • From: Ron Fleckner <email@hidden>
References: 
 >How to implement an open dialog in a sheet and process its output? (From: Nathaniel Gottlieb-Graham <email@hidden>)
 >Re: How to implement an open dialog in a sheet and process its output? (From: Ron Fleckner <email@hidden>)

  • Prev by Date: Re: Notification when switching Spaces?
  • Next by Date: NSCoder blues (was Re: How to archive structs like NSRect)
  • Previous by thread: Re: How to implement an open dialog in a sheet and process its output?
  • Next by thread: Re: How to implement an open dialog in a sheet and process its output?
  • Index(es):
    • Date
    • Thread