Re: Restoring Tiger NSTableView behaviour in Leopard
Re: Restoring Tiger NSTableView behaviour in Leopard
- Subject: Re: Restoring Tiger NSTableView behaviour in Leopard
- From: "K. Darcy Otto" <email@hidden>
- Date: Fri, 11 Apr 2008 14:34:04 -0700
On 11-Apr-08, at 1:07 PM, Corbin Dunn wrote:
On Apr 11, 2008, at 11:38 AM, K. Darcy Otto wrote:
The application I am working on is essentially one big table, and
I'd like to restore at least one aspect the default tab behaviour
that Tiger used when editing tables. Namely, when the user is at
the end of the row and hits tab, I'd like editing to begin at the
beginning of the next row. I note that here,
http://www.cocoabuilder.com/archive/message/cocoa/2007/10/31/191866
the issue is acknowledged, and a solution proposed. The solution
is to subclass NSTableView and implement -(void)textDidEndEditing:
(NSNotification *)notification, but I'm having a problem with the
implementation. Here is what I have so far:
-(void)textDidEndEditing:(NSNotification *)notification
{
NSDictionary *userInfo = [notification userInfo];
int textMovement = [[userInfo valueForKey:@"NSTextMovement"]
intValue];
if (textMovement == NSTabTextMovement)
{
// Tab pressed!
[super textDidEndEditing:notification];
}
}
So, I get to "Tab pressed!", but then don't know how to implement
editing of the first column of the next row. I think I could do
this if I could figure out what column had just finished being
edited. I suppose I could create a variable in the subclass that
stores this information when editing begins; but I was thinking
there should be a property I can just read (and I'm not sure what
property that is). When I use -selectedColumn on the NSTableView,
I don't get anything useful (-1), because apparently no column is
selected (I do get useful information from -selectedRow; but this
isn't quite what I need). Thanks.
____________________________________________
Use
- (NSInteger)editedColumn;
- (NSInteger)editedRow;
You can store it off, call super, then begin editing on the next row/
column (if it was already at the last column).
corbin
Thank you; that fixed it. Here is my solution (for a 4-column table):
-(void)textDidEndEditing:(NSNotification *)notification
{
NSInteger editedColumn = [self editedColumn];
NSInteger editedRow = [self editedRow];
NSDictionary *userInfo = [notification userInfo];
int textMovement = [[userInfo valueForKey:@"NSTextMovement"] intValue];
if (textMovement == NSTabTextMovement)
{
[super textDidEndEditing:notification];
if (editedColumn == 3)
{
// Select row before calling -(void)editColumn:, and then start
editing
[self selectRowIndexes:[NSIndexSet indexSetWithIndex:editedRow+1]
byExtendingSelection:NO];
[self editColumn:0 row:editedRow+1 withEvent:nil select:YES];
}
}
else if (textMovement == NSBacktabTextMovement)
{
[super textDidEndEditing:notification];
if (editedColumn == 0)
{
// Select row before calling -(void)editColumn:, and then start
editing
[self selectRowIndexes:[NSIndexSet indexSetWithIndex:editedRow-1]
byExtendingSelection:NO];
[self editColumn:3 row:editedRow-1 withEvent:nil select:YES];
}
}
else
[super textDidEndEditing:notification];
} // textDidEndEditing
_______________________________________________
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