Reply for cocoa-dev:

Eric is right -- NSTableView won't do tracking in a cell if the shift or alt keys are down. This is intentionally done, and has always been the case.

A possible work around is what Eric is thinking about, which is to override mouseDown and do his own trackMouse logic. Note that it probably should call super first, in order to select the said row before hand.

corbin

On Jan 15, 2009, at 2:10 PM, Eric Gorr wrote:

Thanks.

Any thoughts on whether or not it is even valid to call trackMouse when obtaining a cell this (via preparedCellAtColumn) way?

On Jan 15, 2009, at 4:16 PM, Corbin Dunn wrote:

You want -frameOfCellAtRow:column:, not frameOfOutlineCellAtRow:row.

Do you get a call to this method, if implemented on your delegate/ datasource:

- (BOOL)outlineView:(NSOutlineView *)outlineView shouldTrackCell: (NSCell *)cell forTableColumn:(NSTableColumn *)tableColumn item:(id) item

corbin

On Jan 15, 2009, at 12:53 PM, Eric Gorr wrote:

Now, one idea I had was to override the mouseDown method of my NSOutlineView to do something like:

- (void)mouseDown:(NSEvent *)theEvent
{
 NSPoint     eventLocation   = [theEvent locationInWindow];
NSPoint localPoint = [self convertPoint:eventLocation fromView:nil];
 NSUInteger  modifierFlags   = [theEvent modifierFlags];
BOOL withShiftKey = ( modifierFlags & NSShiftKeyMask ) == NSShiftKeyMask; BOOL withCmdKey = ( modifierFlags & NSCommandKeyMask ) == NSCommandKeyMask;

 NSInteger   row     = [self rowAtPoint:localPoint];
 id          item    = [self itemAtRow:row];

 if ( withShiftKey || withCmdKey ) {
MyCellClass *aCell = (MyCellClass *)[self preparedCellAtColumn:0 row:row];
     NSRect cellRect = [self frameOfOutlineCellAtRow:row];

[aCell trackMouse:theEvent inRect:cellRect ofView:self untilMouseUp:YES];
 }

 [super mouseDown:theEvent];
}

Now, obviously, this isn't complete. For example, a lot more checking needs to be done to make sure if I really want to call trackMouse as I do have group rows and no special processing is needed for them.

Unfortunately, this also doesn't work as I am uncertain how to get the correct frame for the cell in the table. I am also not certain if it would even be valid to call trackMouse when obtaining the cell in this way.

If anyone has any thoughts or comments, I am interested.


On Jan 14, 2009, at 4:19 PM, Eric Gorr wrote:

I am using the pattern found in the excellent PhotoSearch sample code (http://developer.apple.com/samplecode/PhotoSearch/ index.html) to do some custom mouse tracking in a custom NSTextFieldCell.

Unfortunately, if I am holding down the Cmd or Shift key when I click in a cell, the trackMouse method in my custom cell is not called.

In my custom cell, I have multiple items. These items can themselves be selected or not and I need to be able to handle the standard selection behavior normally associated with the shift & cmd keys.

Is there anything I can do about it?
_______________________________________________

_______________________________________________

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 arch...@mail-archive.com

Reply via email to