OS X 10.8.2, XCode 4.5.2.
I have a textbox that I need to limit input to numeric, 3 digits (3 must be 003) between 0 and 360 inclusive. I also need to trap the Enter key.
My thought was to do the validation in a keyDown method. After a lot of searching and reading, it seems I need to have
This code is in my app delegate, as is all the other code that interacts with the UI.
None of those three methods fire. I think something's not wired correctly, but no idea what.
I'd also welcome any comments if catching the keys in keyDown isn't the best way to go.
I have a textbox that I need to limit input to numeric, 3 digits (3 must be 003) between 0 and 360 inclusive. I also need to trap the Enter key.
My thought was to do the validation in a keyDown method. After a lot of searching and reading, it seems I need to have
Code:
- (BOOL)acceptsFirstResponder
{
NSLog(@"Accepting...");
return YES;
}
- (BOOL)becomeFirstResponder
{
NSLog(@"becoming...");
return YES;
}
- (void)KeyDown:(NSEvent *)event
{
NSLog(@"a key wuz prest");
NSString *characters = [event charactersIgnoringModifiers];
if([characters isEqualToString:@"v"])
{
}
}
This code is in my app delegate, as is all the other code that interacts with the UI.
None of those three methods fire. I think something's not wired correctly, but no idea what.
I'd also welcome any comments if catching the keys in keyDown isn't the best way to go.