Re: Add and Edit a table row
Re: Add and Edit a table row
- Subject: Re: Add and Edit a table row
- From: Stephane Sudre <email@hidden>
- Date: Tue, 7 Mar 2006 18:30:51 +0100
On 7 mars 06, at 15:39, Pete Bates wrote:
In an editable table, when the user tabs out of the last cell, rather
than wrapping to the table's first cell, I would like to add a new
row and edit the first cell of the new row. I have tried subclassing
the window to catch the keydown event then adding an object to my
datasource for the table, reloading the table data, and using –
editColumn:row:withEvent:select: to edit the leftmost new cell. This
approach has two problems: first, the window in question will have 3
such tables. How do I know from which table the keyDown event
originated? Do I need an"activeTable" ivar to track this... seems
kind of kludgy. The second issue is that I have not been able to
select the desired cell for editing using
editColumn:row:withEvent:select: Instead, the entire (former) last
row is selected. Now the table view and data source both have the
additional (row/data object) added, and I can manually select and edit
the new row.
Doesn't seem like this is such a novel idea, but I haven't been able
to locate a prior solution. If anyone has an answer, a suggestion, or
can point me to a previous discussion, I'd appreciate it. Thanks.
Would it work if:
- you implement - (void)controlTextDidEndEditing:(NSNotification
*)aNotification in your tableViews delegate.
- (1) Now, you pray that @"NSTextMovement" is included in the userInfo
dictionary.
- In case, it's there: you can now how the edition ended:
textMovement = [[aNotification userInfo] objectForKey:
@"NSTextMovement"];
if ([(NSNumber *)textMovement intValue]==NSTabTextMovement)
{
}
- You then perform a selector with a delay (to exit the notification
and let the NSTableView deal with its internal stuff) which will:
1. add a line to your table data
2. Reload the array so that the NSTableView knows there is one more
row to display.
3. Select the last row and call editColumn:row:withEvent:select:
Everythings depends on (1). I haven't checked this information is
present.
_______________________________________________
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