• 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: Menu and views
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Menu and views


  • Subject: Re: Menu and views
  • From: Sherm Pendley <email@hidden>
  • Date: Tue, 23 May 2006 12:06:00 -0400

On May 23, 2006, at 10:19 AM, Livio wrote:

Developing a Cocoa program I've a problem with menu actions and views (I am new at Cocoa):

have a menu <Insert objects> in the main menu (declared in the "MainMenu.nib" file) whose actions must involve a window view of class "MyView" (from NSView), and the window is declared in a separate file "Windows.nib".
How can I target the menu action to the window view? And how can I enable-disable the menu when necessary? Note that I can have multiple windows and multiple documents.

Connect your actions to "First Responder" in the main menu nib. That will route them to the responder chain, which is automatically updated whenever the current document and/or window changes. It will also automatically disable the menu item if nothing in the responder chain implements the requested action.


I read about automatic targeting, seeking through firstResponder until it reaches the responding view, but is there a flag or what else to set initializing the view? I mean, if I just put aNSTextField in the window (in InterfaceBuilder) the <cut, cpy, paste...> menu items are automatically enabled and work with the TextEditField... but nothing happens with MyView.
How can I do?

Have you implemented -acceptsFirstResponder in your MyView class? The default returns NO, so unless you've overridden that, your object won't be in the responder chain.


Have you implemented the appropriate (cut, copy, paste) actions in your MyView class? If not, the corresponding menu items will be greyed by the automatic menu validation.

You've probably already read this, but just in case:

<http://developer.apple.com/documentation/Cocoa/Conceptual/ BasicEventHandling/index.html>

iMac 500MHz

Wow, a Mac that's slower than my trusty old G4/500! I feel a *little* better now... :-)


sherm--

Cocoa programming in Perl: http://camelbones.sourceforge.net
Hire me! My resume: http://www.dot-app.org

_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden


References: 
 >Menu and views (From: Livio <email@hidden>)

  • Prev by Date: Re: NSWindowController confusion redux
  • Next by Date: Re: Bug in PDFKit's PDFDocument attributes?!
  • Previous by thread: Menu and views
  • Next by thread: Text/Font Size Measurement
  • Index(es):
    • Date
    • Thread