Re: NSTableView NSTrackingArea and mouse clicks
Re: NSTableView NSTrackingArea and mouse clicks
- Subject: Re: NSTableView NSTrackingArea and mouse clicks
- From: "email@hidden" <email@hidden>
- Date: Fri, 25 Jul 2008 13:19:45 -0700
corbin,
thanx for the reply. i was pretty sure it wasn't my drawing code and
after some more "playing around" i'm convinced of that.
i've narrowed down my problem (and i can reproduce it in the
PhotoSearch demo -- see below).
the -[NSCell setHighlighted:] message does NOT get sent to a cell if
a click occurs inside an NSTrackingArea for the cell/view.
to see this problem in the PhotoSearch demo app, add the following 3
lines to the bottom of -[ImagePreviewCell
addTrackingAreasForView:inRect:withUserInfo:mouseLocation:] :
cellFrame.size.width /= 2;
NSTrackingArea *area2 = [[NSTrackingArea alloc]
initWithRect:cellFrame options:options owner:controlView
userInfo:userInfo];
[controlView addTrackingArea:area2];
[area2 release];
also add an override of setHighlighted as follows:
- (void) setHighlighted: (BOOL) value
{
NSLog(@"%s: %d", __func__, value);
[super setHighlighted: value];
}
you can verify that the new tracking area is working because if you
move the mouse into it, the info button changes. but if u click in
this second tracking area, your override of setHighlighted does NOT
get called.
offhand, i would say that this doesn't sound like a bug in
PhotoSearch, but rather a bug in the toolbox. would you agree? if you
think this is a bug in PhotoSearch, can you suggest a solution? if
this is in fact a toolbox bug, let me know and i'll report in radar;
and also, could you suggest a work-around?
thanx,
ken
At 7:44 AM -0700 7/25/08, Corbin Dunn wrote:
On Jul 24, 2008, at 6:16 PM, email@hidden wrote:
i have an NSTableView that uses a data source (no bindings, but i
don't think this is relevant). one column uses a custom cell that
is actually a subclass of NSTokenFieldCell (but i don't think this
is relevant either). i draw this cell differently depending on
whether or not the row it is in is the table's selected row. (and i
only allow one row at a time to be selected.)
if i don't use any NSTrackingAreas, everything works as i want/expect.
however, if i set up some tracking rects for my custom cell, then
things don't work properly. i am using the techniques from the
sample PhotoSearch app. by "don't work properly," what i mean is
that if i select a row by clicking in one of the NSTrackingAreas,
the cell draws as if the row isn't selected. if i don't click
inside one of the tracking rects, but click elsewhere in the row,
then my custom cell draws properly, ie in its highlighted state.
since this is my first use of NSTrackingArea, i wouldn't be
surprised if its something i'm doing. are there known interactions
between NSTrackingArea a clicks in the tracking area? can anyone
suggest how i can proceed?
No; none --- it is probably something wrong with your cell drawing
code. Can you post it here? I'll take a look at it.
corbin (I wrote that demo -- note, I think there are a few bugs in
the tracking area code of the demo that I need to fix up, but this
isn't one of them)
_______________________________________________
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