Contextual Menus for an NSOutlineView
Contextual Menus for an NSOutlineView
- Subject: Contextual Menus for an NSOutlineView
- From: Justin Wood <email@hidden>
- Date: Thu, 22 Nov 2001 05:59:53 -0500
I've been trying to get this working for some time now, but to no avail, its
got me quite puzzled.
I have an NSOulineView displaying all sorts of data and I need to create
contextual menus for some of the items. It seemed quite easy, the delegate
method:
- (void)outlineView:(NSOutlineView *)outlineView willDisplayCell:(id)cell
forTableColumn:(NSTableColumn *)tableColumn item:(id)item
Hands us a nice referece to the cell, which is apparantly a descendant of
NSCell. NSCell seems to have the method, - [NSCell setMenu:(NSMenu *)menu].
So I tried to use this, no response at all. In my searching around, I found
a mention that I should try setting the actual data cell for the
tableColumn, so I tried that... [[tableColumn dataCell] setMenu: myMenu],
still no dice.
If I actually set the outlineView's menu ( [oulineView setMenu: myMenu] ),
then I can get a menu, but for the whole view. And it doesn't pass the
clicks through. For example, if I click where one of the rows should be
(control click that is), no row is selected, it just pops open a contextual
menu, which makes sense, as I set the menu for the entire view, not each
cell.
Anyway! The long and short of it is, I have no idea what to do, and I'd
appreciate any advice anyone might have, I'm sure there must be a relatively
simple way of doing this, it doesn't seem to be a feature that is quite 'out
there'.
Thanks in advance... I need to grab some shut eye :)
- Sincerely,
Justin Wood