Is there a way to force capitals in a NSTextField?
I want to create a text field for typing in Post Codes, and I want all post codes entered to use capital letters.
e.g. N1 3ET instead of: n1 3et
Also, I am using a regular expression, which only accepts capitals (I know very little about regular expressions, so I'm not keen on modifying it)
Thank you!
Michael
You could give the NSTextField a delegate with something along the lines of:
- (void)controlTextDidChange:(NSNotification *)aNotification{
NSText *fieldEditor = [[aNotification userInfo] objectForKey:@"NSFieldEditor"];
[fieldEditor setString:[[fieldEditor string] uppercaseString]];
}
It should catch text changing notifications and uppercase the text.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With