Re: contextual menu in NSTableView cell
Re: contextual menu in NSTableView cell
- Subject: Re: contextual menu in NSTableView cell
- From: Chris Meyer <email@hidden>
- Date: Fri, 17 Jan 2003 14:44:36 -0800
You need something like this (I think I originally pilfered this from
the archives of this list):
@implementation NSTableView (MyTableViewExtensions)
-(NSMenu*)menuForEvent:(NSEvent*)evt
{
NSPoint point = [self convertPoint:[evt locationInWindow]
fromView:NULL];
int column = [self columnAtPoint:point];
int row = [self rowAtPoint:point];
if ( column >= 0 && row >= 0 && [[self delegate]
respondsToSelector:@selector(tableView:menuForTableColumn:row:)] )
return [[self delegate] tableView:self
menuForTableColumn:[[self tableColumns] objectAtIndex:column] row:row];
return NULL;
}
@end
then implement 'tableView:menuForTableColumn:row:' in your table view
delegate.
On Friday, January 17, 2003, at 02:05 PM, stupidFish programming wrote:
>
hi,
>
>
i want to have a contextual menu to pop-up when ctrl-clicked on a
>
table's given cell.
>
i tried to do the following:
>
>
- (void)tableView:(NSTableView *)view willDisplayCell:(id)cell
>
forTableColumn:(NSTableColumn *)col row:(int)row
>
{
>
[cell setMenu:theMenu];
>
}
>
>
but it doesn't give me a the menu. am I completely in the wrong
>
direction?
>
>
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.
_______________________________________________
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.