Resign key for a non-activating floating utility panel in BG app?
Resign key for a non-activating floating utility panel in BG app?
- Subject: Resign key for a non-activating floating utility panel in BG app?
- From: Evan Gross <email@hidden>
- Date: Mon, 23 Sep 2002 05:12:56 -0400
Hi all,
I've taken advantage of the new NSPanel feature that avoids activating the
application in a background-only (LSUIElement) app I'm working on.
All seems just dandy, works like a charm in general (it's the UI Server for
an Input Method).
Just one thing I can't figure out - I want to be able to make the panel
resign as the key window with a keystroke (I override NSPanel and implement
keyDown). This happens automatically whenever you click somewhere other than
my panel, and I have no problem making the panel key again via makeKeyWindow
when the key is resigned this way.
BUT everything I've tried (three nights on it so far) to resign it
programmatically has failed in some subtle way, preventing makeKeyWindow
from working properly afterwards. You can't simply call resignKeyWindow (and
the docs say that you should never call this anyway) - it kind of works, but
has side-effects. If you call [NSApp deactivate] that will ALSO resign the
key window, but it doesn't actually deactivate the application ([NSApp
isActive] returns YES (even later on, I realize an app may not deactivate
immediately). When I'm in this state (no key window, but app isActive),
which I end up in via most things I've tried makeKeyWindow just doesn't
work.
I need the equivalent of Carbon's SetUserFocusWindow(kUserFocusAuto) (which
I also tried - doesn't do anything at all - no big surprise) which will
remove the key focus from a (Carbon) utility window and "give it back" to
the most likely candidate. In my case (and yes, I've done this with a Carbon
window) this would be the application that my Input Method's panel is being
used with (well, at least it would go to the front app's frontmost window).
When my panel resigns key via a mouse click in the frontmost app (or menu
bar, etc.), [NSApp isActive] returns NO. When my panel becomes key
afterwards via makeKeyWindow, [NSApp isActive] becomes YES. Whatever I've
tried programmatically results in the window resigning key, but [NSApp
isActive] returns YES after my window controller gets the windowDidResignKey
message. Calling [NSApp deactivate] at that point doesn't seem to do
anything.
Calling SetFrontProcess() on the frontmost application also does nothing
(because it's already front!).
So the question is: how can I programmatically make my pane resign key the
same way (no idea what that is) it happens in response to a user event?
Thanks for any ideas, (and no, [window makeFirstResponder:nil] didn't do a
whole lot)
Evan Gross
Rainmaker Research Inc.
_______________________________________________
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.