[comp.sys.next] Owner of a delegate ...

CMH117@psuvm.psu.edu (Charles Hannum) (05/08/90)

A have a Window (actually a Panel, but that's irrelevant).  I have a delegate
for the Window.  I connected the delegate in the Interface Builder.  Now, my
problem:

  When the delegate receives a message (like a call to windowDidBecomeKey), is
  there a way to directly determine which Window the message is in reference to
  without using an outlet in the delegate's class?

It seems like there should be an easy way to do this, but I can't seem to find
it.


Virtually,
- Charles Martin Hannum II         PennMUD Design Team - (Resident) Programmer
    (That's Charles to you!)       "Those who say a thing cannot be done should
  Please send mail to:              under no circumstances stand in the way of
  hannum@haydn.psu.edu              he who is doing it." - a misquote

eps@toaster.SFSU.EDU (Eric P. Scott) (05/08/90)

In article <90127.154746CMH117@psuvm.psu.edu> CMH117@psuvm.psu.edu
	(Charles Hannum) writes:
>  When the delegate receives a message (like a call to windowDidBecomeKey), is
>  there a way to directly determine which Window the message is in reference to
>  without using an outlet in the delegate's class?

windowDidBecomeKey: takes a sender argument; whether it conveys
useful information I'll leave as an exercise to the reader.

My best advice is not to write code such that the question comes
up at all, but if you must--read the descriptions of keyWindow
(Application) and isKeyWindow (Window) and see if those tell
you what you want to know.

					-=EPS=-

dayglow@csli.Stanford.EDU (Eric T. Ly) (05/08/90)

In article <90127.154746CMH117@psuvm.psu.edu> CMH117@psuvm.psu.edu (Charles Hannum) writes:

>A have a Window (actually a Panel, but that's irrelevant).  I have a delegate
>for the Window.  I connected the delegate in the Interface Builder.  Now, my
>problem:
>
>  When the delegate receives a message (like a call to windowDidBecomeKey), is
>  there a way to directly determine which Window the message is in reference to
>  without using an outlet in the delegate's class?

Usually, a message that your delegate receives will include a "sender"
argument.  This is true for the windowDidBecomeKey: delegate method.
The "sender" refers to the Window object that something has happened
to, so for instance, when your delegate gets a windowDidBecomeKey:
message, the sender refers to the Window which just became the
key window.

Hope this helps.


						Eric Ly