G'Day Jim,
How's it go'n down there??
OK.... I have a TextField that I will need to evaluate every key entry as the end user types in a value - is this just a normal IBAction ??
Pete
Brisbane
- (void)controlTextDidChange:(NSNotification *)aNotification
{
NSTextField* textField = [aNotification object];
NSString* newValue = [textField stringValue];
NSLog(@"%s: %@", __PRETTY_FUNCTION__, newValue);
// TODO: React to changed text field
}
Jim,
Take a look at this link:
http://pagesofinterest.net/blog/2010/11/subclassing-nstextfield-to-allow-only-numbers/
Seeing that the NSTextField I want to use needs to handle a numeric number - would this example be the best way out for me??
Pete
-(void)textDidChange:(NSNotification *)aNotification
{
[self setIntegerValue:[self integerValue]];
[super textDidChange:aNotification];
}
Afternoon Jim,
Settled with your code - works great - all I will need to do is convert the newValue to a float.
One thing I am failing to understand and hope you may steer me in the right direction.
In your code there is no reference to the TextField pointer I am using yet your code responds to my user input - how does this happen if I have made no reference in you code?
Pete
So, what you're saying is, as NSTextField inherits the NSText object which has the textDidChange delegate which will post a notification when an end user taps a key.
Then the method you wrote will handle all messages associated with the Notification?
What would happen if the interface has a number of TextFields within, I guess the coder then will need to reference using 'id' ?