Re: Making a application active with NSStatusMenus
Re: Making a application active with NSStatusMenus
- Subject: Re: Making a application active with NSStatusMenus
- From: Andrew James <email@hidden>
- Date: Mon, 26 Feb 2007 14:31:34 +1030
Well im using a IB connection to make the windows become key and to
the front, however some windows are also automated (AS Script
application im working on, display dialogs etc) i would prefer not to
create individual IBActions for every menu item (Doing this would
still leave the automated windows out of it)
Below is a link to a example project i used to test the bug, the code
i added to try and using the windowBecameKey: is
- (void)windowDidBecomeKey:(NSNotification *)aNotification{
NSLog(@"hello");
}
http://att.macrumors.com/attachment.php?attachmentid=69127&d=1172453411
PS. Im also using LSUIElement = 0 in my other applications if thats
useful to anyone
when a item in the menu is selected say the About item
it will call the window and make it key but the application is not
brought
to the front.
Is there a way to detect when a window opens or when the menu is
used so i
can make the application come to the front, ive tried
windowBecameKey but
could not get it to work but it may of been a mistake on my side.
The delegate method is windowDidBecomeKey: (note the colon), not
windowBecameKey. Was that a typo in your email?
How are you making the window come to front? Are you using an IB
connection between the menu item and the window? If so, are you
using -makeKeyAndOrderFront: as the action method? If not, that
might be why windowDidBecomeKey: isn't getting called -- it didn't
become key. Another reason might be if the About window is an
NSPanel, in which case it might not be able to become key -- see
the "How Panels Work" link in the NSPanel docs.
Do you really want the whole application to come to the front
whenever the About window comes to front (including switching
windows within the application), or only when the *menu* is used to
open the About panel? If the latter, you might want to write an
action method for the menu item and have the action method first
call [NSApp activateIgnoringOtherApps:YES] and then open the About
window. If necessary, you could check the sender argument to see
if it's an NSMenuItem.
--Andy
_______________________________________________
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