Re: [NEWBIE]: Dynamically loading NSViews
Re: [NEWBIE]: Dynamically loading NSViews
- Subject: Re: [NEWBIE]: Dynamically loading NSViews
- From: "M. Uli Kusterer" <email@hidden>
- Date: Sat, 2 Oct 2004 18:32:04 +0200
At 15:18 Uhr +0100 02.10.2004, J Tichenor wrote:
They are loaded from the main menu NIB.
Then I think we can cut this whole problem short if you simply put
all your views into an NSTabView and hook them up in IB that way. You
can hide the tabs on an NSTabView.
I thought about that, figuring that would be the most obvious thing.
But as far I can tell, you can't explicitly set the delegate of a
custom NSView in IB.
If the delegate instance variable is declared as an IBOutlet, you
can. Or, if your view I subclassed from NSControl, it will also
notice the delegate outlet. I have the creeping fear that whatever
"custom view" this is, you're doing something very wrong. What kind
of custom view is this? You said they were text fields at first.
Just note that a delegate is nothing in NSView. Either you declare
your own, or you inherit one from a superclass.
And the ivar for the views won't accept the -setDelegate method,
What "ivar for the views"? What type is it? What object is it in?
so I just assumed that once the view was added as a subView,
delegation is covered by the superview.
I think you don't quite understand what a delegate is. A delegate is
simply an object that will receive certain messages from the view,
and is thus able to customize that view's behavior. Delegates are
solely for you, the programmer. Superviews or other objects don't
mess with that.
Are you perhaps mixing up the responder chain and delegates? That's
two entirely different things.
Yeah, that's fine. It worked fine when a single view was hooked into
the window. It's just now that one of three views is loaded
dynamically that the method isn't called -- whether by tabbing or
entering..
That's because you didn't tell the view who is its delegate. You
need to do that explicitly.
I've set up the browser as firstResponder for the Window, and the
main window NSView as the nextKeyView (right or wrong?).
"Main window NSView"? I think you're doing too much. Leave
initialFirstResponder and nextKeyView alone. They're only needed when
you want to customize the tabbing order in your window. If you don't
set them, AppKit will take care of everything and use sensible
defaults. That should be enough for you for now.
When I wasn't trying to dynamically load one of these three views, I
could be in the browser and then tab out to the first NSTextField in
the window's bottom view -- hope that makes sense.
Essentially, I could tab from my browser into the firstResponding
textField in the view, before implementing this dynamic loading of
different views.
Have you read the Hillegass book yet? It describes very clearly what
the initial first responder and nextKeyView are for. You might want
to try re-reading those parts.
--
Cheers,
M. Uli Kusterer
------------------------------------------------------------
"The Witnesses of TeachText are everywhere..."
http://www.zathras.de
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden