Re: [SOLVED, with reservations] Re: Turn off menu highlight in outline view?
Re: [SOLVED, with reservations] Re: Turn off menu highlight in outline view?
- Subject: Re: [SOLVED, with reservations] Re: Turn off menu highlight in outline view?
- From: Graham Cox <email@hidden>
- Date: Tue, 18 Aug 2009 11:46:29 +1000
On 18/08/2009, at 2:27 AM, Corbin Dunn wrote:
Copied below is the pertinent information:
NSTableView/NSOutlineView - Contextual menu support
NSTableView and NSOutlineView now have better contextual menu
support. Please see the DragNDropOutlineView demo application for
an example of how to properly do contextual menus with a TableView.
The key thing to note is that clickedRow and clickedColumn will now
both be valid when a contextual menu is popped up. In addition, one
can dynamically set the popup menu for a particular cell/column in
the delegate method willDisplayCell:. NSTableView handles this by
properly overriding menuForEvent:, setting the clickedRow/
clickedColumn, and calling [NSCell menuForEvent:inRect:ofView] to
find the correct menu. If no menu was returned, the menu for the
NSTableView will be used. If one right clicks on a selection of
items, all the items are highlighted. One should check to see if
clickedRow is one of the selected rows, and if it is then do the
menu operation on all the selected rows. The clickedRow and
clickedColumn properties will still be valid when the action is
sent from the NSMenuItem.
Unfortunately, you may have stumbled upon one deficiency; there is
no way to have the menu apply for the table as a whole. As you
discovered, the way to fix this is to override -menuForEvent:.
Hi Corbin, thanks for the clarification. I didn't re-read the release
notes when looking for information on this I must admit, though the
exact wording doesn't immediately clarify the precise issue. But I do
understand the thinking a little better now. This though:
If no menu was returned, the menu for the NSTableView will be used.
Suggests to me that a good behaviour might be to not draw the default
row highlight in this case. If the cell returns a menu, then fine, the
menu must pertain to the row, and so the highlight is appropriate. But
if the table falls back to the view's menu, the row highlight isn't
appropriate, no?
However, even better would be a setting -
setShouldDrawRowHighlightForContextualMenu: or something (or another
delegate method), which just refers the problem to the developer. For
compatibility with the current implementation, this could default to
YES.
I'm open to suggestions and ways on improving things -- please do
log bugs and/or enhancement requests, and ways you would expect the
highlighting to work but does not.
I haven't lodged a bug yet, but will once I know what a sensible
suggestion would be.
--Graham
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden