Re: Make About window respond to ⌘W in UI-less application
Re: Make About window respond to ⌘W in UI-less application
- Subject: Re: Make About window respond to ⌘W in UI-less application
- From: Ron Fleckner <email@hidden>
- Date: Tue, 27 Apr 2010 15:08:42 +1000
On 27/04/2010, at 8:21 AM, Michael Dippery wrote:
I'm building a Cocoa application that runs as an item in the status
bar, and I'm using LSUIElement to prevent the app's icon from
appearing in the Dock. This application has an About window and an
item to activate that window, using the standard Cocoa mechanism for
doing so (that is, -[NSApplication orderFrontStandardAboutPanel:]).
It works great except for one thing: unlike most About windows, it
shows up _underneath_ all other windows, rather than on top. I
worked around this by creating an IBAction in my app's controller
that first brings the app to the front, and then shows the window,
like so:
- (IBAction)orderFrontStandardAboutPanel:(id)sender
{
[NSApp activateIgnoringOtherApps:YES];
[NSApp orderFrontStandardAboutPanel:sender];
}
This causes the About window to appear on top of other windows, but
the window does not respond to the ⌘W keyboard event; instead, I
just get the system alert beep, indicating that nothing is in place
to handle the event. Since I don't have a reference to the About
window (as it's created by NSApplication) I can't figure out how to
hook up a mechanism for handling the keyboard event, and it doesn't
seem to get passed to my app controller, even though it's a delegate
of NSApp (if I understand the responder chain correctly, NSApp will
pass some unhandled events on to its delegate).
Is there a way to get the About window to respond to ⌘W?
Thanks,
Hi Michael,
Don't why it's not working for you. My LSUIElement app similarly has
no menu bar or dock icon, but it's various ancillory windows (About
plain vanilla version, Preferences) respond to key board short cuts
which are set in the main menu nib. I have done no special hacks to
achieve this, it Just Works™.
Does your app have a MainMenu nib file?
Ron
_______________________________________________
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