Re: Help for responders...
Re: Help for responders...
- Subject: Re: Help for responders...
- From: Daniel Jalkut <email@hidden>
- Date: Thu, 5 Apr 2007 09:56:02 -0400
On Apr 4, 2007, at 10:06 AM, Jay wrote:
Thanks for your reply, Daniel,
My current problem is that, I have added the menuitem in IB, I have
added the "toggleRuler" method in the cutomerView class and
implemented it in .m file, but I have no idea for what to do next.
I noticed that the menuitem I chose "ShowRuler" is already by
default connected to the "1st Responder" instance icon in the
MainMenu.nib window, but I have no idea whether it should be
reconnected to somewhere else in order to connect to the
"toggleRuler" method implemented in the cutomerView class. Thanks.
Should I make an instance of the customView as well in the nib file?
Hi Jay - it sounds like a lot of questions will disappear for you if
you become a bit more comfortable with "the responder chain" and how
it works with your application. In particular, you want to get a good
understanding of how "first responder" represents more than just the
focused view - it also represents every parent of that view
(typically), and ultimately some key delegates such as a the window's
delegate and the application delegate.
http://developer.apple.com/documentation/Cocoa/Conceptual/
CocoaFundamentals/CoreAppArchitecture/chapter_7_section_6.html
Short story short: you leave your menu item wired up to first
responder, but you add the "toggleRuler:" (note the colon not
included in your text) method not to the specific view that will have
its ruler toggled, but to some class that is guaranteed to be in the
responder chain when the menu item should be selectable.
The custom view may still have a "toggleRuler:" method, but if it's
not in the responder chain, and you still want to allow the user to
toggle it, then some other object in the responder chain (possibly
the window's delegate or the NSDocument) needs to take responsibility
for passing that message along.
This is probably hard to take in, so read the documentation linked
above. You will probably also benefit from listening to Aaron
Hillegass speak on the subject in his interview on Late Night Cocoa:
http://latenightcocoa.com/?q=node/56
Good luck!
Daniel Jalkut
http://www.red-sweater.com/blog/
_______________________________________________
Cocoa-dev mailing list (email@hidden)
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