[comp.sys.next] Window as Outlet

pegasus@quiche (PROVOST philippe) (06/15/90)

hello,


I know that it may seems stupid, but how can i  Link a window displayed and
defined by IB to an outlet (named windowIB for instance) , ie how to get that
window in your code ?
my problem is i have defined a specific kind of View, and i would like to
"plug" it within that window. how do i have to proceed ?

Help very much appreciated


	Phil

wb1j+@andrew.cmu.edu (William M. Bumgarner) (06/15/90)

This is one of those "Ouch, got ya!" problems-- since you can't
instantiate a view w/o actually dragging out a copy in IB, there is no
way to make connections to that view from IB.

The solution:

1-  if at all possible, if the window you want to tie the view to
exists in IB, even if you can't make the view have the attributes you
want, you can instantiate that way and then in the +newFrame or
-appDidInit (application delegate method), adjust the views attributes
to what you want...

2- if the window doesn't exist (tieing the view to the appIcon or
doing something else goofy on the fly) you can do the following:

you will need an object (either subclass of window or just an object
that is instantiated) that has an outlet connected to the window so it
can send messages to the window.  In that objects new method, do the
following:

instance variables:
 id myView;
 id myWindow;


+ new
{
  self = [super new];
  myView = [SpecialViewClass newFrame:theRect]; /* or new */

  return self;
}

now in appDidInit (so you know the window has been instatiated and can
be messed with:

-appDidInit
{
  [myWindow addSubView:myView]; /* or something similar, I can't
remember the exact call-- I'm doing this off the top of my head.  You
could also add your view so it is the contentView */
 /* do whatever other mods you want in here */

return self;
}

Hope this helps-- mail if you have any questions.  I won't be back
online til monday, but will be happy to help more if necessary...

BTW:  Anyone ever notice how primitive a MacPlus keyboard feels after
using a NeXT keyboard all day??  This message was some serious typing
effort, it seems...

b.bumgarner            | Disclaimer:  All opinions expressed are my own.
wb1j+@andrew.cmu.edu   | I officially don't represent anyone unless I
NeXT Campus Consultant | explicity say I am doing so. So there. <Thpppt!>
"I ride tandem with the random/Things don't run the way I planned them.."