Preventing clicks in floating utility panels from activating app?
Preventing clicks in floating utility panels from activating app?
- Subject: Preventing clicks in floating utility panels from activating app?
- From: Evan Gross <email@hidden>
- Date: Fri, 05 Oct 2001 20:11:43 -0400
Hi all,
I've noticed some "interesting" behavior with a floating utility NSPanel in
my app w.r.t. the way that clicks in controls do or don't activate my
application.
This window has a toolbar, an editable NSTextField and a couple of buttons
at the top of the window (below the toolbar, of course), an enabled,
non-editable/selectable NSTextField below that, and a non-editable (but
selectable) NSTextView occupying occupying the rest (bottom portion) of the
window. I call setFloatingPanel:YES] and setBecomesKeyOnlyIfNeeded:YES in
its window controller's windowDidLoad method. The window can be opened in
response to a selection from the Services menu (among other ways).
I've noticed that:
1. There's no problem opening the window in response to the Services menu
selection - it appears and my app doesn't activate (this seems quite normal
- you have to explicity activate your app - if that's what you want - in
this situation).
2. Clicking in certain controls/widgets works as you'd expect, but DOESN'T
activate my app (the behavior I generally want). This includes the show/hide
toolbar widget, the area of my toolbar that has no items, the scrollbar for
the NSTextView, the resize widget (I can resize the window without
activating my app), the enabled (but NOT editable or selectable)
NSTextField, and (as per the UI guidelines) I can drag the window without
activating it IF the command-key is down. This is also the case if there is
some text selected in my NSTextView and I initiate a drag.
3. Clicking in any other control (NSButton, toolbar item, NSTextView) OR in
the content are of the window not occupied by any control *immediately*
activates my application, tracking the mouse in the control (pretty much
normally), all before the mouse button is released.
3a. One exception to 3. above is the NSTextView (probably doesn't return YES
from acceptsFirstMouse). The first click activates my app, I have to click
again to select the text in it or have my NSTextView delegate's
clickedOnLink method called.
Ideally, I'd like to make this window fully functional without ever
activating my app. It should be open-able (via the Services menu) and
operable (I guess with the exception of keyboard equivalents), keeping the
current app active so the user can keep on typing and/or operate my window.
This way they don't have to worry about manually switching back to what they
were working on due to a click in my window activating my app.
I've messed a bit with subclassing NSApplication and overriding sendEvent,
trying to get what I want by calling NSApplication's preventWindowOrdering
method after a mouse down in my window (and before) without any success.
Anyone have any idea why I see different app activation behavior for
different controls (2 and 3 above)? Anyone know if what I want to do is
possible, and how it might be done?
Thanks for any thoughts!
Evan Gross
Rainmaker Research Inc.