Hi Charles-

On Jun 7, 2008, at 9:44 PM, Charles Jenkins wrote:

With regard to my problems with delegates, I think maybe my frustrations stem from something about the delegation process or about text fields that I do not understand.

There's just a little twist to NSTextField that you are missing when it comes to delegation. The methods you've identified are not actually delegate methods that NSTextField will call; they are rather methods on NSTextField that will be called during the editing process. The methods you are interested in implementing in your controller are delegate methods in NSControl (NSTextField's superclass), and are called:

- (BOOL)control:(NSControl *)control textShouldBeginEditing:(NSText *)fieldEditor
- (void)controlTextDidBeginEditing:(NSNotification *)aNotification

respectively. Both have the benefit of passing along which control is the subject of the edit (the first in the method signature, the second accessible with a key in the notification), so you won't have to go through the Carbon technique you used to figure out which field was getting edited.

I think the secret to getting this type of thing right is that the documentation uses the end of the instance methods list for a class to call out specifically when methods are delegate methods. Look at the end of NSControl's list and you can see a special section entitled delegate methods, while NSTextView's list does not contain such a declaration.

Hope this helps - good luck with your learning!

John

_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]

Reply via email to