Hi ken,

It took me a minute to realize it, but what you describe below makes sense. Let me clarify what preparedCellAtColumn:row: does; this is the main funnel point that NSTableView uses to get a cell to do any operations (ie: drawing, type selection, etc). NSTableView's implementation gives you a cell set up with the correct state (ie: selected, etc).

Now, what does the TrackableOutlineView app do? It *copies* this cell (and any state it had), and returns that copy in preparedCellAtColumn:row:. So, you mouse in, it copies the cell and starts returning that cell. If you click down, well, NSTableView never gets a chance to set the state, since you override preparedCellAtColumn:row:.

Make sense? It is working correctly; it's not a bug in PhotoSearch or the framework (also -- we use the term AppKit or framework, but "toolbox" refers to another framework).

Of course, you want it to not work that way. You want it to reflect the state that NSTableView sets. So, a quick hack:

- (NSCell *)preparedCellAtColumn:(NSInteger)column row:(NSInteger)row {
// We check if the selectedCell is nil or not -- the selectedCell is a cell that is currently being edited or tracked. We don't want to return our override if we are in that state. if ([self selectedCell] == nil && (row == iMouseRow) && (column == iMouseCol)) { NSCell *superCell = [super preparedCellAtColumn:column row:row];
        [iMouseCell setHighlighted:[superCell isHighlighted]];
        return iMouseCell;
    } else {
        return [super preparedCellAtColumn:column row:row];
    }
}

.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 PROTECTED] 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 (Cocoa-dev@lists.apple.com)

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]

Reply via email to