我以编程方式创建了一个 NSPopUpButton 并为我的选择创建了一个数组,如何为每个单独的数组选择创建一个 setAction?谢谢!
NSRect buttonRect = NSMakeRect(1705, 145, 78, 50);
//Button Array. When I pick the choice it closes the diologue box
NSArray *newArray;
NSString *color1 = @"Blue Color";
NSString *color2 = @"Green Color";
NSString *color3 = @"Clear Color";
newArray = [NSArray arrayWithObjects: color1, color2, color3, nil];
NSPopUpButton *button = [[NSPopUpButton alloc] initWithFrame:buttonRect pullsDown:YES];
[self addSubview:button];
[button addItemsWithTitles:newArray];
//want my action for each individual string
[button setAction:@selector(changeFilterColor)];
-(void) changeFilterColor
{
NSLog(@"colorChanged");
}