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 352653
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T11:45:26+00:00 2026-05-12T11:45:26+00:00

I am having a problem. My contextual menu is getting displayed but the menu

  • 0

I am having a problem. My contextual menu is getting displayed but the menu items are not activated.
so my new code for displaying the menu is as follows:

NSMenu *defMenu = [[[NSMenu alloc] initWithTitle:@"default Contextual Menu"] autorelease];

[defMenu insertItemWithTitle:@"Open" action:@selector(openFile) keyEquivalent:@"" atIndex:0];

[defMenu insertItemWithTitle:@"Delete" action:@selector(deleteFile) keyEquivalent:@"" atIndex:1];

return defMenu;

and function declaratons of deleteFile and openFile are as follows:

-(int)openFile;

-(int)deleteFile;

and i am calling my contextual menu as follows:

-(void)doSingleClick 
{

    if([[NSApp currentEvent] modifierFlags] & NSControlKeyMask)
    {

        NSLog(@"control clicked.......");

        [NSMenu popUpContextMenu:[self defaultMenu] withEvent:[NSApp currentEvent] forView:tableView];

        return;
    }

}

my contextual menu items are all shaded and cannot be clicked. Please can you tell where i am going wrong.

Thanks

  • 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-05-12T11:45:26+00:00Added an answer on May 12, 2026 at 11:45 am

    Your openFile: method takes an int as a parameter. Since insertItemWithTitle:action:withObject:keyEquivalent:atIndex: takes an object, the selector you give it must also take an object.

    You can use NSNumber to wrap your int as an object, and simply change your openFile: method to take an NSNumber rather than an int. Like so:

    [defMenu insertItemWithTitle:@"Open" action:@selector(openFile:) withObject:[NSNumber numberWithInt:5] keyEquivalent:@"" atIndex:0];
    
    - (void)openFile:(NSNumber *)fileNumber {
        int rowClicked = [fileNumber intValue];
        // Do whatever your old method did here
    }
    

    EDIT: To answer your updated question:

    The reason your menu items are disabled is that you’ve only told them what method name to call. You never told the items on which object instance those methods should actually be called. To fix this, you need to set the items’ target:

    NSMenuItem *openItem = [defMenu insertItemWithTitle:@"Open" action:@selector(openFile:) withObject:[NSNumber numberWithInt:5] keyEquivalent:@"" atIndex:0];
    [openItem setTarget:self];
    

    And so forth for each item you’ve got.

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

Sidebar

Ask A Question

Stats

  • Questions 231k
  • Answers 231k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer You don't need to redirect. Do: WSGIDaemonProcess multithreaded processes=1 threads=15… May 13, 2026 at 2:11 am
  • Editorial Team
    Editorial Team added an answer When you do something like: char *f(){ return "static string";… May 13, 2026 at 2:11 am
  • Editorial Team
    Editorial Team added an answer This will dynamically take your myValue, replace all ?'s with… May 13, 2026 at 2:11 am

Related Questions

I am working on an ASP.NET MVC project and I am trying to get
I have the following challenge, and I haven't found a good answer. I am
The issue I'm currently having is mapping multiple GUI fields to object properties (i.e.
I am currently refining my design process for developing websites, scripts, and web-based applications.

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.