Re: NSOutlineView, tracking in a custom NSTextFieldCell, & Shift&Cmd Keys
Re: NSOutlineView, tracking in a custom NSTextFieldCell, & Shift&Cmd Keys
- Subject: Re: NSOutlineView, tracking in a custom NSTextFieldCell, & Shift&Cmd Keys
- From: Corbin Dunn <email@hidden>
- Date: Thu, 15 Jan 2009 13:16:14 -0800
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 (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