Please help a newbie with delegation!
Please help a newbie with delegation!
- Subject: Please help a newbie with delegation!
- From: Adam Wainwright <email@hidden>
- Date: Fri, 25 Feb 2005 18:26:07 +0000
Hi Folks
Sorry to be a pain but could someone help me with delegation?
I have, say, a nib file with two NSTextField items, named textField1 and textField2.
I have implemented the code below with nothing else. In the init() method I have used setDelegate:self to act as delegates to the NSTextFields and I have then just created dummy routines to grab the output and just say they are doing stuff.
Nothing is called.
I have also tried to ctrl-drag a link in IB from the text boxes to the AppController class and connect 'delegate'.
I guess this is a stupid question: where am I going wrong?
In reality I am wrestling with the old 'NSStepper-NSTextField' conundrum. I want to update the value of a stepper when someone types a number in a box. Am I barking up the wrong tree?
Many thanks for your help.
Adam
Header:
/* AppController */
#import <Cocoa/Cocoa.h>
@interface AppController : NSObject
{
IBOutlet NSTextField *textfield1;
IBOutlet NSTextField *textfield2;
}
- (BOOL)textShouldEndEditing:(NSText *)textObject;
- (void)textDidChange:(NSNotification *)aNotification;
- (void)textDidBeginEditing:(NSNotification *)aNotification;
- (void)textDidEndEditing:(NSNotification *)aNotification;
- (BOOL)textShouldBeginEditing:(NSText *)textObject;
@end
Implementation:
#import "AppController.h"
@implementation AppController
- (BOOL)textShouldEndEditing:(NSText *)textObject
{
NSLog(@"Am in textShouldEndEditing");
return YES;
}
- (BOOL)textShouldBeginEditing:(NSText *)textObject
{
NSLog(@"Am in textShouldBeginEditing");
return YES;
}
- (void)textDidEndEditing:(NSNotification *)aNotification
{
NSLog(@"Am in textDidEndEditing");
}
- (void)textDidBeginEditing:(NSNotification *)aNotification
{
NSLog(@"Am in textDidBeginEditing");
}
- (void)textDidChange:(NSNotification *)aNotification
{
NSLog(@"Am in textDidChange");
}
- (id) init
{
super init];
[textfield1 setDelegate:self];
[textfield2 setDelegate:self];
return self;
}
@end
--
Does dim atal y llanw!
_______________________________________________
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