• 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: How do I implement contextual-menu to NSTableView/NSOutlineView
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: How do I implement contextual-menu to NSTableView/NSOutlineView


  • Subject: Re: How do I implement contextual-menu to NSTableView/NSOutlineView
  • From: Ondra Cada <email@hidden>
  • Date: Tue, 29 Jan 2002 19:44:53 +0100

Gore,

>>>>>> Gore (G) wrote at Tue, 29 Jan 2002 17:36:31 +0200:
G> I would like to have a NSMenu to be displayed as a contextual-menu when
G> right-clicking on an item in the table view/outline view. Is this
G> possible ?

Yep, and quite easily -- just like more or less anything in Cocoa ;).

You have to re-implement menuForEvent: of the TableView. My own solution
(which uses a delegate to provide the actual menu for an appropriate cell)
looks like this -- use it freely should you want to:

@implementation NSTableView (DateSelection)
-(NSMenu*)menuForEvent:(NSEvent*)evt {
NSPoint pt=[self convertPoint:[evt locationInWindow] fromView:nil];
int column=[self columnAtPoint:pt],row=[self rowAtPoint:pt];
if (column>=0 && row>=0 && [[self delegate]
respondsToSelector:@selector(menuForTableColumn:row:)])
return [[self delegate] menuForTableColumn:[[self tableColumns]
objectAtIndex:column] row:row];
return nil;
}
@end
---
Ondra Cada
OCSoftware: email@hidden http://www.ocs.cz
2K Development: email@hidden http://www.2kdevelopment.cz
private email@hidden http://www.ocs.cz/oc


References: 
 >How do I implement contextual-menu to NSTableView/NSOutlineView (From: Gore <email@hidden>)

  • Prev by Date: view rotation and autoresizing of subviews
  • Next by Date: Simple C Question
  • Previous by thread: Re: How do I implement contextual-menu to NSTableView/NSOutlineView
  • Next by thread: Re: How do I implement contextual-menu to NSTableView/NSOutlineView
  • Index(es):
    • Date
    • Thread