I'm running into a weird problem. I have two NSTExtFields representing a username and a password. When I get an incorrect username/password combination, I set an instance variable stating so in the controller of the view containing those two fields. I then use key-value observing to run the following method when the instance variable changes:
- (void)handleCredentialsValidityToggle {
if ([self areCredentialsValid]) {
[passwordField setBackgroundColor:[NSColor colorWithCalibratedRed:1.0 green:1.0 blue:1.0 alpha:1.0]];
[usernameField setBackgroundColor:[NSColor colorWithCalibratedRed:1.0 green:1.0 blue:1.0 alpha:1.0]];
} else {
[passwordField setBackgroundColor:[NSColor colorWithCalibratedRed:1.0
green:1.0
blue:0.35
alpha:1.0]];
[usernameField setBackgroundColor:[NSColor colorWithCalibratedRed:1.0
green:1.0
blue:0.35
alpha:1.0]];
}
}
This works fine as long as a field isn't active. In other words, if I modify the one of the fields, keep it in focus with the cursor inside, and try to authenticate (by clicking a menu item), the field with the focus does not update to the new background color, while the field without the focus does.
In order to see if I could force it to update, I added the following lines to the end of the method:
[passwordField drawCell:[passwordField cell]];
[usernameField drawCell:[usernameField cell]];
Still no luck. Anyone have any ideas what could be causing this? Thanks in advance!