Re: runModalForWindow is disabling my menus
Re: runModalForWindow is disabling my menus
- Subject: Re: runModalForWindow is disabling my menus
- From: "Pascal J. Bourguignon" <email@hidden>
- Date: Sat, 05 Sep 2015 15:45:41 +0200
- Organization: Informatimago
On 05/09/15 14:14, Felipe Monteiro de Carvalho wrote:
Hello,
I want to have a modal window which has menus, so I setup the menus
for the window and make it modal with NSApp.runModalForWindow and
everything is OK, except that my menu items are all disabled!
I tried to forcefully enable them, by implementing validateMenuItem
and returning always true, but it doesn't work.
Each menu item has itself as target and a method to respond to the action.
If I only change from runModalForWindow to a non-modal window show,
then everything works ok!
Any ideas or is it impossible to have menu items and use runModalForWindow?
I have a hard time understanding whats the problem here and why the
menus won't just work.
I searched Google and other people had this problem, but noone solved
it. It seams that few people use modal windows with menus, by the way
as there were not that many discussions about it.
AFAIK, it's on purpose. Definitely in the case of an application modal
dialog.
In the case of a window modal dialog, you can switch to another window,
and then have access to the menubar, but within the context of the
window modal dialog, you the menus are disabled.
runModalForWindow makes an application modal dialog.
So I would rather try to use|-[NSWindow beginSheet:completionHandler
<https://developer.apple.com/library/mac/documentation/Cocoa/Reference/ApplicationKit/Classes/NSApplication_Class/#//apple_ref/occ/instm/NSApplication/beginSheet:modalForWindow:modalDelegate:didEndSelector:contextInfo:>].|
Where did you put the validateMenuItem? The object implementing
validateMenuItem must be the target of the |/menuItem. /|
--
__Pascal J. Bourguignon__
http://www.informatimago.com/
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please 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