Re: window de/activation notifications (was Re: inappropriate tool palette activation problem)
Re: window de/activation notifications (was Re: inappropriate tool palette activation problem)
- Subject: Re: window de/activation notifications (was Re: inappropriate tool palette activation problem)
- From: Uli Kusterer <email@hidden>
- Date: Fri, 19 Oct 2007 23:27:15 +0200
Am 19.10.2007 um 22:02 schrieb John Richetta:
I tend to be a stickler for UI details, but I admit that I hadn't
noticed a distinct "frontmost in its layer" highlight.
To see it, open the "Addresses" window in Mail. When it comes up,
it initially has a black window title, and the widgets have black
outlines and are opaque, too. However, the title bar background has
the inactive, striped appearance. If you now explicitly click the
window, it actually becomes active, and you see that because the
window widgets actually take on color, and the title bar background
gets the gradient instead of the pinstripes.
Once you click the Addresses window, you'll also notice that the
Mail window itself deactivates half-way. The title bar gets a softer,
whiter gradient, but the title text stays black. Only if you switch
out the application, or open a second Mail Viewer main window or a
message window, you'll get the real inactive appearance with the
pinstripes, inactive title text and the semi-transparent widgets.
IIRC floaters only have the two states, because they are either
available, or hidden when the app is in background, so I guess nobody
bothered implementing that appearance.
(this terminology which was previously very clear on Mac OS is no
longer consistently applied in the documentation; often, but not
always, the NeXT terminology of "ordering front" is used, or the
term "main" - which doesn't appear to be really precisely defined
anywhere).
It is, somewhere, but I don't remember where I read it. Have you
checked the HIG or Hillegass' book?
It took me a while to determine how to obtain these notifications.
In older Mac OS, these were events delivered to all apps, without
requesting them specially,
Well, only because all events were delivered to everyone in the
main event loop. Since in Cocoa the event loop (NSRunLoop) is owned
by the framework, it gets dispatched differently.
but now, apparently, one must subscribe to the didBecomeMain and
didResignMain notifications. I've done this, and these
notifications are being sent to my documents, which then message
the inspector appropriately.
Actually, what you really want to do is implement -
windowDidBecomeMain: etc. in your window delegate (which is usually
the document class), but you may have to explicitly hook that up in
the NIB.
However, either I am getting too many notifications, or I don't
understand their meaning correctly.
If you're explicitly registering, and your notification method
happens to be named windowDidBecomeMain:, you could be getting the
message twice (once via delegation, the second time via your explicit
request). Also, you have to specify the object for the notification.
If you specify NIL there, you'll get notifications for every window,
instead of just for the object you're interested in. Could any of
these be your problem?
It may help to re-read Hillegass and the NSNotification(Center)-
and delegate-related documentation to make sure you understand these
concepts and how everything is set up to work.
In general, when in other frameworks you would subclass a framework
class, in Cocoa you instead use delegation. The advantage of
delegation is that you aren't forced to have the delegate be a
distinct object. It could just be an existing other object. I.e. you
can have one delegate that handles several similar windows, or one
delegate that handles a window, and also is the delegate of the views
in that window... everything that makes sense conceptually, and
within the Model-View-Controller scheme.
Cheers,
-- M. Uli Kusterer
http://www.zathras.de
_______________________________________________
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