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

Re: NSTableView w/Contextual Menu


  • Subject: Re: NSTableView w/Contextual Menu
  • From: Corbin Dunn <email@hidden>
  • Date: Thu, 17 Aug 2006 09:37:59 -0700

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

You need to be a little more specific. Exactly what isn't working? What are you doing, what are you seeing, and what are you expecting?



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;
}

Note that do to the returns above, the rest of the code below won't execute.


--corbin


[[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,

_______________________________________________
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


References: 
 >NSTableView w/Contextual Menu (From: Brian Amerige <email@hidden>)

  • Prev by Date: Basic UI behavior
  • Next by Date: Re: NSTextFieldCell Subclass in IB
  • Previous by thread: NSTableView w/Contextual Menu
  • Next by thread: Re: NSTableView w/Contextual Menu
  • Index(es):
    • Date
    • Thread