FROM : Glenn Andreas
DATE : Fri Nov 19 20:07:27 2004
At 12:02 PM -0600 11/19/04, John Spicer wrote:
>I'm building a menu at run-time. I add items to the menu, and each
>one is given a selector as shown.
>
>The menu items won't enable. I'm not setting a target for the menu
>item, only a selector. Is this possibly the problem?
It depends.
If your object that implements the routine method is in the responder
chain, it will work fine. If it isn't, it won't (unless something
else in the responder chain responds to that selector).
By default, the target is NULL which means "look it up through the
first responder (and then up the chain)". This is often the way you
want things to work if the menu corresponds to something which may
have multiple instances (in multiple windows for different document,
for example) since otherwise you may end up doing "foo" on the wrong
window's "foo view". On the other hand, if it is something that is a
singleton (only one exists in your app) you'll want to set the target
to that object (since singletons like this rarely are in the
responder chain).
--
Glenn Andreas <email_removed>
<http://www.gandreas.com/> oh my!
Mad, Bad, and Dangerous to Know
DATE : Fri Nov 19 20:07:27 2004
At 12:02 PM -0600 11/19/04, John Spicer wrote:
>I'm building a menu at run-time. I add items to the menu, and each
>one is given a selector as shown.
>
>The menu items won't enable. I'm not setting a target for the menu
>item, only a selector. Is this possibly the problem?
It depends.
If your object that implements the routine method is in the responder
chain, it will work fine. If it isn't, it won't (unless something
else in the responder chain responds to that selector).
By default, the target is NULL which means "look it up through the
first responder (and then up the chain)". This is often the way you
want things to work if the menu corresponds to something which may
have multiple instances (in multiple windows for different document,
for example) since otherwise you may end up doing "foo" on the wrong
window's "foo view". On the other hand, if it is something that is a
singleton (only one exists in your app) you'll want to set the target
to that object (since singletons like this rarely are in the
responder chain).
--
Glenn Andreas <email_removed>
<http://www.gandreas.com/> oh my!
Mad, Bad, and Dangerous to Know
| Related mails | Author | Date |
|---|---|---|
| John Spicer | Nov 19, 19:02 | |
| Jesus De Meyer | Nov 19, 19:06 | |
| John Spicer | Nov 19, 19:52 | |
| Glenn Andreas | Nov 19, 20:07 |






Cocoa mail archive

