Re: iTunes-like single-click table cell editing
Re: iTunes-like single-click table cell editing
- Subject: Re: iTunes-like single-click table cell editing
- From: Camillo Lugaresi <email@hidden>
- Date: Wed, 19 Jan 2005 00:12:52 +0100
On 18/gen/05, at 23:39, Benjámin Salánki wrote:
Hi all,
I was searching through the archives for the last hour but couldn't
find anything, so let me ask you:
how can I implement single-click (or delayed double-click) editing
like the one in iTunes?
does anyone have some code example?
I assume you're talking about single-click editing of text cells in an
NSTableView. I wanted to do that a while ago, and the method I came up
with was to make a custom subclass of NSTableView which overrides
mouseDown:
- (void)mouseDown:(NSEvent *)event
{
NSPoint location = [self convertPoint:[event locationInWindow]
fromView:nil];
int columnIndex = [self columnAtPoint:location];
int rowIndex = [self rowAtPoint:location];
if ((rowIndex >= 0) && ([[[[self tableColumns]
objectAtIndex:columnIndex] dataCellForRow:rowIndex]
isKindOfClass:[NSTextFieldCell class]])) {
[self selectRow:rowIndex byExtendingSelection:NO];
[self editColumn:columnIndex row:rowIndex withEvent:event select:YES];
} else [super mouseDown:event];
}
It's not exactly the same interface as iTunes, but it should be easy to
adapt this code to your needs.
Note, however, that I wrote this code for my first or second Cocoa
program ever and never touched it again; it could well be that there
are better ways to do the same thing.
HTH
Camillo
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden