[SOLVED, with reservations] Re: Turn off menu highlight in outline view?
[SOLVED, with reservations] Re: Turn off menu highlight in outline view?
- Subject: [SOLVED, with reservations] Re: Turn off menu highlight in outline view?
- From: Graham Cox <email@hidden>
- Date: Mon, 17 Aug 2009 21:49:36 +1000
On 17/08/2009, at 10:21 AM, Graham Cox wrote:
I have an outline view using source list style.
When I right-click on the view, the item under the mouse highlights
with a blue outline independent of the current selection. This gives
the impression that the menu command applies to that item, not the
real selected item. In my case my menu commands pertain to the list
as a whole, and therefore the current normal selection, so I'd like
to turn off this additional highlight.
How? I couldn't find any means to do this, using a delegate method
or otherwise.
I solved this initially by going right back to basics and overriding
the -rightMouseDown: method, and just handling the menu there. There
is presently no public method of NSTableView/NSOutlineView that is
exposed for specifically dealing with the standard item highlighting
for the menu.
There is a curiosity here though. I did this, which is fine for what I
wanted:
- (void) rightMouseDown:(NSEvent*) event
{
NSMenu* menu = [self menu];
if( menu )
[NSMenu popUpContextMenu:menu withEvent:event forView:self];
}
But if I do this, which appears to be more correct:
- (void) rightMouseDown:(NSEvent*) event
{
NSMenu* menu = [self menuForEvent:event];
if( menu )
[NSMenu popUpContextMenu:menu withEvent:event forView:self];
}
...then I get the highlight back again! This indicates that the
NSOutlineView's implementation of this highlight is being done in a
dubiously skanky way, drawing directly as part of the -menuForEvent:
method, rather than flagging the menu tracking and drawing as part of
the standard drawing mechanism. So, to prove that, I ended up doing
this:
- (NSMenu*) menuForEvent:(NSEvent*) event
{
#pragma unused(event)
return [self menu];
}
...which also gives the desired result, suppressing the highlight. It
means that one surprising side-effect of returning a menu in -
menuForEvent: built in code will be that if you want the standard row
highlight, you won't get it without invoking super, even if you don't
want super's menu.
It seems strange to me that this method is doing highlighting duty
when all it's meant for is to return a property.
Bugs will be filed...
--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