• 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
Responding to menu items
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Responding to menu items


  • Subject: Responding to menu items
  • From: Darrin Cardani <email@hidden>
  • Date: Tue, 23 Sep 2003 16:19:02 -0500

I'm working on my first Cocoa application. I've been going through Aaron Hillegass' book "Cocoa Programming for Mac OS X", and it's got a lot of good information in it. I'm a long time PowerPlant user, so I may just not be seeing the way Cocoa handles things, but I'm a little confused about something. (Or I just may not have gotten to the chapter where this is described in more detail, yet.)

I have my MainMenu.nib file, which contains just my menu bar and related menu resources. Then I have my MyDocument.nib file which contains my document's object and window. The window contains an NSMovieView, and I have a menu item called "Open Movie...". I would like to present the user with an open file dialog, allow them to choose the movie, and display the chosen movie in the NSMovieView. I have something which works, but it seems a tad convoluted to me.

The problem is that in my mind, I should have a method called something like "openMovie" in my MyDocument class, and choosing the "Open Movie..." menu item should send the openMovie message to my document class. However, the MyDocument object is in MyDocument.nib and the menu item is in MainMenu.nib, so I can't make a connection between them in Interface Builder. I could put them into 1 nib file, but presumably, that's not the way it's done. I could also hook them up programmatically, but I suspect that's more work than I really need to do.

What I've done is create an AppController class, and added that to MainMenu.nib. It receives the openMovie message, then uses the shared document controller to get the current document and forwards the message to it. Is this the standard way of doing things? Is there a more direct way to do things? Am I going to need an AppController in most of my applications, which will do this sort of message forwarding?

Thanks,
Darrin
--
Darrin Cardani - email@hidden
President, Buena Software, Inc.
<http://www.buena.com/>
Video, Image and Audio Processing Development
_______________________________________________
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: Responding to menu items
      • From: Chris Hanson <email@hidden>
  • Prev by Date: Re: What ever happened to "shared frameworks"?
  • Next by Date: Don't launch helpers with Webkit?
  • Previous by thread: Re: Providing feedback if file can not open
  • Next by thread: Re: Responding to menu items
  • Index(es):
    • Date
    • Thread