First Responder (was "Re: Enable the Copy Menu")
First Responder (was "Re: Enable the Copy Menu")
- Subject: First Responder (was "Re: Enable the Copy Menu")
- From: Lorenzo <email@hidden>
- Date: Tue, 02 Sep 2003 10:45:21 +0200
Hi,
I already implemented copy: and validateMenuItem: but it didn't work.
Anyway, thanks to you (you wrote "responder") I found the origin of the
problem. I forgot to add the "first responder" to the object that I create
programmatically and add to a mainView... So, now I do:
[mainView addSubview:myObject];
[[mainView window] makeFirstResponder:myObject];
Now, since there is a NSTextField in my Window too, I would like to select
my object typing the TAB key. So any time I type the TAB key, the selection
switches from the NSTextField to myObject, then to the NSTextField again.
Do you know ho to get this work?
Should I use one of this APIs?
- (BOOL)resignFirstResponder
- (BOOL)becomeFirstResponder
- (BOOL)acceptsFirstResponder
Thank you so much.
Best Regards
--
Lorenzo
email: email@hidden
>
> Hi,
>
> I can programmatically enable/disable the other menu items but not the
>
> "Copy" Menu. I noted that the "Edit" menu has the flag "Auto Enabled
>
> Items"
>
> on.
>
> If I deactivated this check-box I can programmatically enable/disable
>
> the
>
> "Copy" menu, but this way I loose the nice "auto enabling" feature on
>
> the
>
> text selections.
>
>
>
>
>
> Do you know how to let my object enable/disable the "Copy" menu without
>
> loosing the "auto enabling" feature?
>
> Thank you.
>
>
>
>
>
>
>
>
Using autoenabling, Cocoa searches the responder chain for objects that
>
respond to the action associated with the menu item. If you look at the
>
Copy menu item, its action message is copy:, so add that action to your
>
object and it should be enabled. You can also create a
>
validateMenuItem: method in your object, where you can then
>
enable/disable that menu item based on the context of your object, like
>
if nothing is selected, you can disable the Copy menu item. Using
>
validateMenuItem: allows you to override autoenabling.
>
>
Don
_______________________________________________
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.