• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
menu item validation in tableView context menu
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

menu item validation in tableView context menu


  • Subject: menu item validation in tableView context menu
  • From: stupidFish programming <email@hidden>
  • Date: Sat, 18 Jan 2003 09:41:57 +0100

Hi,

I hope someone can help me on this one, as I am pretty much stuck right
now.
I have a tableView and want to display a contextual menu for its rows.
I subclassed the tableView and overrode the
-(NSMenu*)menuForEvent:(NSEvent*)theEvt function and used its delegate
for the menu creation. In the delegate i have set up a function which
decides on wether to show the menu or not by looking at the selected
row. now I checked if this function gets called or not by NSLog()ing
the parts:

-(id)menuForTableColumn:(int)aCol row:(int)aRow
{
if (aRow >= [activeRecords count] || aRow < 0)
{
NSLog(@"no menu");
return nil;
}
else
{
NSLog(@"do menu");
return theMenu;
}
}

and the menu gets created.
I set up the menu programmatically in the delegate's
-(void)awakeFromNib function:

theMenu = [[NSMenu alloc] initWithTitle:@"context menu"];
NSMenuItem* renameMenuItem = [[NSMenuItem alloc]
initWithTitle:NSLocalizedStringFromTable(@"Rename", @"LocalizeThis",
@"Rename") action:@selector(renameItem:) keyEquivalent:@""];
[renameMenuItem setEnabled:YES];
[renameMenuItem setTarget:self];
[theMenu addItem:renameMenuItem];

now my problem is that even though the menu shows up (and only where I
want it to show up), but the item is disabled. I tried to set
setAutoEnablesItems: to NO, which gave me an enabled item, but the
connected action won't start.

what am I doing wrong?

thanks,

Ben
_______________________________________________
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.

  • Prev by Date: implementing pop up menus
  • Next by Date: Re: cocoa-java problem
  • Previous by thread: Re: implementing pop up menus
  • Next by thread: contextual menu in NSTableView cell - NEW
  • Index(es):
    • Date
    • Thread