Re: Problem with validateMenuItem and a Modal Dialog, maybe a bug in Cocoa...
Re: Problem with validateMenuItem and a Modal Dialog, maybe a bug in Cocoa...
- Subject: Re: Problem with validateMenuItem and a Modal Dialog, maybe a bug in Cocoa...
- From: Hannes Friederich <email@hidden>
- Date: Wed, 22 Jan 2003 20:56:37 +0100
I don't know whether this helps or not, but you could try to set the target
of the menu item to the first responder. This way, all requests should be
forwarded to the current window and from there to the associated window
controller. It's the same way the menu validation works for the save, open
items etc.
>
>
According to the Cocoa documentation:
>
>
validateMenuItem:
>
>
- (BOOL)validateMenuItem:(id <NSMenuItem>)menuItem
>
>
Implemented to override the default action of enabling or disabling
>
menuItem. The object implementing this method must be the target of
>
menuItem. It returns YES to enable menuItem, NO to disable it. You can
>
determine which menu item menuItem is by querying it for its title,
>
tag, or action.
>
>
----------------------------
>
>
This is working fine in the main window of my application.
>
>
o Now I have a NSTextField subclass instance in a NSPanel run as a
>
Modal dialog.
>
o There is a NSMenu attached to this NSTextField subclass instance. (to
>
the menu outlet)
>
o In this NSMenu, there's a NSMenuItem whose target is my NSPanel
>
controller.
>
>
o The NSPanel control implements the - (BOOL)validateMenuItem:(id
>
<NSMenuItem>)menuItem method.
>
>
When the NSMenu attached to the NSTextField subclass is displayed (via
>
a simple click), all its items are disabled and the validateMenuItem:
>
method is not called.
>
>
When I click on a NSPopUpButton item in this same NSPanel, the
>
validateMenuItem: method is called.
>
>
I checked at awakeFromNib and indeed the target and action of the
>
NSMenuItems of the NSMenu attached to the NSTextField subclass instance
>
are correct.
>
>
Is there some kind of magic to have validateMenuItem: be called for my
>
NSTextField subclass instance or do I just need to fill a bug report?
_______________________________________________
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.