comboBox and notifications
comboBox and notifications
- Subject: comboBox and notifications
- From: Yury Peskin <email@hidden>
- Date: Fri, 2 Apr 2004 16:30:30 -0600
Hi List,
I have a very strange problem happening, and I'm hoping somebody on
this list will know the answer.
The setup: OS X 10.3.3.
The problem: I have an app in which I have a comboBox, when the
comboBox does not have a selection in it, I would like the label of the
comboBox to be red, and if there is a selection I would like the label
to be black. This works, IF the user uses a keyboard to select the
string. If the user uses the mouse it does not work. I've traced it
to the setControlColor... this function tells me that the cell of the
control contains nothing. Any ideas on how I can accomplish this?
Thanks,
Yury
Here's my code:
-(void) setControlColor:(NSControl *)aControl labelControl:(NSControl
*)aLabelContol
{
if(YES == [[[aControl cell]stringValue] isEqualToString:@""])
{
NSLog(@"change to red");
[[aLabelContol cell] setTextColor:[NSColor redColor]];
}
else
{
NSLog(@"change to black");
[[aLabelContol cell] setTextColor:[NSColor blackColor]];
}
}
- (void)controlTextDidChange:(NSNotification*)aNotification
{
if([aNotification object] == self->purchaseOrderNumberField)
{
[self setControlColor:self->purchaseOrderNumberField
labelControl:self->purchaseOrderNumberLabel];
}
if([aNotification object] == self->yourEmailAddressField)
{
[self setControlColor:self->yourEmailAddressField
labelControl:self->yourEmailAddressLabel];
}
if([aNotification object] == self->mailToEmailAddressField)
{
[self setControlColor:self->mailToEmailAddressField
labelControl:self->mailToEmailAddressLabel];
}
}
-(void) comboBoxSelectionDidChange:(NSNotification*) aNotification
{
NSLog(@"comboBoxSelectionDidChange");
if([aNotification object] == self->purchaseOrderNumberField)
{
[self setControlColor:self->purchaseOrderNumberField
labelControl:self->purchaseOrderNumberLabel];
}
if([aNotification object] == self->yourEmailAddressField)
{
[self setControlColor:self->yourEmailAddressField
labelControl:self->yourEmailAddressLabel];
}
if([aNotification object] == self->mailToEmailAddressField)
{
NSLog(@"mailToEmailAddressField");
[self setControlColor:self->mailToEmailAddressField
labelControl:self->mailToEmailAddressLabel];
}
}
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.