• 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: Ron Fleckner <email@hidden>
  • Date: Mon, 12 Nov 2007 20:02:25 +1100


On 12/11/2007, at 5:44 PM, Nathaniel Gottlieb-Graham wrote:

Now, I'm pretty new to cocoa, so please have patience with me, but I'm having a heck of a time figuring something out. I have what seems to me to be a very simple task, yet I'm struggling with it. Here it is:

I have an NSDocument-based application, and I want a certain button to, when clicked, display an "open" dialog sheet that only accepts QuickTime movies and then passes the movie the user has chosen into a QTMovieView in the active window. It's primarily the sheet that's giving me trouble; I know this sounds stupid, but I need help simply creating it in response to some user action. Is there any easy code to simply stick in and tweak slightly that implements the modal sheet open dialog that I'm looking for?

My NSDocument subclass has an instance variable wired up to the QTMovieView, but I'm having extreme difficulty getting a movie into it. Once the user selects a movie, will I just dump it into that instance variable, or is there more that's required?

Again, I apologize for my ignorance. I've been wrestling with this stuff for hours and I feel really stupid.


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:didEndSel ector: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.
_______________________________________________


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

  • Prev by Date: Re: troubleshooting unrecognised selector messages
  • Next by Date: Is performFindPanelAction: working properly?
  • Previous by thread: 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