• 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
NSTableView w/Contextual Menu
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

NSTableView w/Contextual Menu


  • Subject: NSTableView w/Contextual Menu
  • From: Brian Amerige <email@hidden>
  • Date: Thu, 17 Aug 2006 11:34:04 -0400

I've looked through all the archives on this exact issue, and followed them point by point, but something still isn't working.

I've subclassed 'NSTableView', 'SpecialTableView', in select the row as well when right clicking.
An outlet ( 'IBOutlet NSMenu *tableContextualMenu') is in 'SpecialTableView.h'.


I've created a menu inside IB, and connected it to my TableView's menu outlet. The following is a method from 'SpecialTableView.m':

- (NSMenu *)menuForEvent:(NSEvent *)theEvent
{
int row = [self rowAtPoint:[self convertPoint:[theEvent locationInWindow] fromView:nil]];
if( row != -1 )
{
NSLog(@"Temp Feedback -Contextual Click on row..");
[self selectRow:row byExtendingSelection:NO];
return menu;
}
else
{
NSLog(@"Temp Feedback -Contextual Click on empty row..");
[self deselectAll:nil];
return menu;
}
[[self window] makeFirstResponder:self];
NSPoint menuPoint = [self convertPoint:[theEvent locationInWindow] fromView:nil];
int row2 = [self rowAtPoint:menuPoint];
BOOL currentRowIsSelected = [[self selectedRowIndexes] containsIndex:row2];
if (!currentRowIsSelected)
{
[self selectRow:row byExtendingSelection:NO];
}
if ([self numberOfSelectedRows] <=0)
{
NSMenu* tableViewMenu = [[self menu] copy];
int i;
for (i=0; i<[tableViewMenu numberOfItems]; i++)
{
[[tableViewMenu itemAtIndex:i] setEnabled:NO];
}
return [tableViewMenu autorelease];
}
else
{
return menu;
}
}


Really appreciate any help,
Brian.




_______________________________________________ Do not post admin requests to the list. They will be ignored. Cocoa-dev mailing list (email@hidden) Help/Unsubscribe/Update your Subscription: This email sent to email@hidden
  • Follow-Ups:
    • Re: NSTableView w/Contextual Menu
      • From: Corbin Dunn <email@hidden>
  • Prev by Date: Rotating an object
  • Next by Date: Re: Rotating an object
  • Previous by thread: Re: Re: Rotating an object
  • Next by thread: Re: NSTableView w/Contextual Menu
  • Index(es):
    • Date
    • Thread