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

  • Home
  • SEARCH
  • 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 5968701
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T20:07:38+00:00 2026-05-22T20:07:38+00:00

I have a TableView with custom cells. I want a contextual menu to appear

  • 0

I have a TableView with custom cells. I want a contextual menu to appear when the user right clicks (or any other Apple variants of right-click) on one of the cells (and know which cell they clicked on).

I tried to subclass NSTableView and overwrite this method:

- (NSMenu *)menuForEvent:(NSEvent *)theEvent;

But it is never being called.

On the other hand,

- (void)rightMouseDown:(NSEvent *)theEvent;

Gets called. But I’m not sure it’s the one we want.

More details:

//
//  PTTableView.m
// 
//
//  Created by Nathan Hazout on 5/31/11.
//  Copyright 2011 __MyCompanyName__. All rights reserved.
//

#import "PTTableView.h"


@implementation PTTableView

- (id)init
{
    self = [super init];
    if (self) {
        // Initialization code here.
    }

    return self;
}

- (void)rightMouseDown:(NSEvent *)theEvent { 
    NSLog(@"entered rightMouseDown");
}

- (NSMenu *)menuForEvent:(NSEvent *)theEvent {
    NSLog(@"entered menuForEvent");
    return [super menuForEvent:theEvent];
}

- (NSView *)hitTest:(NSPoint)aPoint{
    NSLog(@"entered hitTest");
    return [super hitTest:aPoint];
}

- (void)dealloc
{
    [super dealloc];
}

@end

rightMouseDown gets called. hiTest gets called many times. But menuForEvent doesn’t.

  • 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-22T20:07:38+00:00Added an answer on May 22, 2026 at 8:07 pm

    There’s no need to muck about with event handling, all you have to do to assign a contextual menu is set the table view’s menu outlet to point to the NSMenu object that you want to use for the contextual menu.

    You can do this in Interface Builder by dropping an NSMenu object into your nib file and control-dragging from the table view to the menu to set the outlet.

    Alternatively, you can use the -setMenu: method of NSTableView (inherited from NSResponder) to assign the menu programmatically.

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

Sidebar

Related Questions

I want to create a tableview like this. All sections have custom section header
I have a tableview with my custom tableViewCell. The issue that I want to
I have different number of photos in tableview custom cell.Now i want to display
In my iPhone application I have a table view. When user taps any row,
i have tableview with custom cell.the table is divided in many section and rows.i
I have X sections. I want to lazy load images in different Custom Cell
I have an UITableView showing custom view cells that I've designed in interface builder.
I have a table view on a view and table view contains custom cells
I have a custom cell with a uitextfield inside. I want to hide the
I have very custom TableView like Add Contact View in iPhone's Contacts. I like

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.