• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: [NEWBIE]: Dynamically loading NSViews
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [NEWBIE]: Dynamically loading NSViews


  • Subject: Re: [NEWBIE]: Dynamically loading NSViews
  • From: "M. Uli Kusterer" <email@hidden>
  • Date: Sat, 2 Oct 2004 23:03:05 +0200

At 21:01 Uhr +0100 02.10.2004, J Tichenor wrote:
The custom views are just that - the custom view from the IB palette, with an IBOutlet NSView ivar pointing to each one from the controller.

Ah, okay. That's what I would call an NSView as a top-level object in the NIB. So, is this NSView empty, or are there other views inside it? A plain and simple NSView is just a container for other views. It can't have the keyboard focus itself, nor a delegate.

What you'd want to do would be to put your views into this NSView, and hook up the outlets of those views to your other objects. E.g. if you have an NSTextField in your NSView, that NSTextField will have a delegate outlet that you can connect. *not* the NSView around it. For the same reason, if you hook up initialFirstResponder or nextKeyView, you don't connect that to an NSView, but rather to a view that can actually have focus, like your NSTextField. Is that your problem, or did you try that?

Still learning as I go, for sure. My understanding of the delegate is as an object to receive messages as determined by the sending object.

Well, that's not all. That's simply a target of a message. If the object "B" is the delegate of the object "A", then "A" must have a "delegate" outlet that is connected to "B". Depending on how much control "A" offers to its delegates, "A" will send notifications to "B", or it will even call methods on "B" that return a value or are expected to perform a particular action.

E.g. the delegate "B" can make decisions on behalf of "A" (like "can this list item be selected?") or it can perform actions, like accepting objects being dragged onto "A". (that's the case of NSTableView)

Are you perhaps mixing up the responder chain and delegates? That's two entirely different things.

I might well be. I figured delegation runs the same path that the responder chain does, but I guess I've got that mixed up.

No, they're separate. There is usually only one delegate for one object. Think of it as a Minister in parliament: There's only one Minister of the Treasury, or Minister of Foreign affairs (or do you call that "Secretary of State"? I may be mixing up AE and BE again...). Such a Minister is one "delegate".

OTOH, the responder chain is an entire hierarchy. An easy-to-understand example is when a key is pressed. The keypress goes to the first responder. If the first responder is a text field, it accepts the key press and appends the character to its text.

Otherwise, it doesn't accept, and the next higher object in the responder chain gets to see it (e.g. the window) If the window is a dialog panel and the key was "return", then it will trigger a click in the default button. Otherwise it doesn't accept the keypress and hands it on to the application. If the keypress matches a keyboard shortcut, the application will trigger a menu choice in that menu item.

The nextKeyView doesn't really have much to do with the responder either. All it does is set up the tabbing order in a window. It starts with the initialFirstResponder, or the first text field in the window, and when you hit the tab key it progresses to the next text field in the window. I.e. this is just for letting people not use the mouse when working with lots of text fields.

Finally, there's notifications, which are again different, and are a one-to-many matter. One object sends a notification, and anyone interested can register to receive this notification. E.g. there's a notification that lets you detect when the computer goes to sleep or wakes up again, when a CD has been inserted etc.

How do I tell a NSView object who it's delegate is when it doesn't accept the setDelegate message?

An NSView doesn't have a delegate. It wouldn't make sense. All an instance of NSView does is display other views embedded in it, and forward clicks to them. If you have nothing to do, you have nothing to delegate. Select your NSTextField or whatever is inside that NSView. It will have a "delegate" outlet.

--
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
  • Follow-Ups:
    • Re: [NEWBIE]: Dynamically loading NSViews
      • From: J Tichenor <email@hidden>
References: 
 >[NEWBIE]: Dynamically loading NSViews (From: J Tichenor <email@hidden>)
 >Re: [NEWBIE]: Dynamically loading NSViews (From: "M. Uli Kusterer" <email@hidden>)
 >Re: [NEWBIE]: Dynamically loading NSViews (From: "M. Uli Kusterer" <email@hidden>)
 >Re: [NEWBIE]: Dynamically loading NSViews (From: J Tichenor <email@hidden>)

  • Prev by Date: Re: NSDocument New ?
  • Next by Date: Re: [NEWBIE]: Dynamically loading NSViews
  • Previous by thread: Re: [NEWBIE]: Dynamically loading NSViews
  • Next by thread: Re: [NEWBIE]: Dynamically loading NSViews
  • Index(es):
    • Date
    • Thread