Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7795991
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T23:13:59+00:00 2026-06-01T23:13:59+00:00

I have created an NSPopUpButton programmatically and I made an array for my choices,

  • 0

I have created an NSPopUpButton programmatically and I made an array for my choices, how can I create a setAction for each individual array choice? Thanks!

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");

}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-01T23:14:00+00:00Added an answer on June 1, 2026 at 11:14 pm

    You need to add the NSMenuDelegate protocol to your interface (.h file):

    @interface MyClass : NSObject <NSMenuDelegate>
    

    Then:

    [[button menu]setDelegate:self];
    

    after you create the NSPopUpButton. Also, remove the line with setAction:.

    Copy this delegate method:

    -(void)menu:(NSMenu *)menu willHighlightItem:(NSMenuItem *)item
    {
        if ([item.title isEqualToString:@"Blue Color"]) { ... } //etc
    }
    

    Add the necessary if statements to complete the comparisons.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have created my NSPopUpButton programmatically with the following code [myPopUpButton insertItemWithTitle:@--Select one-- atIndex:0];
Have created a small two tab app, then subclassed another view controller to create
I want to create an NSPopUpButton with a custom active image. I have two
i have created a table in mysql to store polygon data: CREATE TABLE geom
I have created a cookie using php and now I need to create a
I have created an edit text box where the user can input information. As
I have created a Scrollviewer in WP7, which harbors 3 usercontrol, each one of
Have created a c++ implementation of the Hough transform for detecting lines in images.
I have created a facebook apps. Works fine for me. It contains canvas url,
I have created a mac application using the WebView. But issue is that webView

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.