Re: Delete row from NSTableView
Re: Delete row from NSTableView
- Subject: Re: Delete row from NSTableView
- From: Daniel Todd Currie <email@hidden>
- Date: Mon, 1 Mar 2004 22:37:54 -0800
In one of my projects I have an NSTableView targetTable, and its data
source NSMutableArray targets. You can remove the selected row like
this:
- (void)removeSelectedRowFromTable
{
[targets removeObjectAtIndex:[targetTable selectedRow]];
[targetTable reloadData];
}
By default, the cells of an NSTableView are not selectable, so you
needn't worry about that.
Getting your table to respond to the delete key is slightly more
complicated. The way I would do it is to subclass NSWindow and
override the -keyDown: method. Make the window containing your table
an instance of your subclass, so that your overridden -keyDown: method
will be called when a key is pressed and that window is in the
responder chain. In your -keyDown: method you can then test the
NSEvent that is passed for which key was pressed, and respond
accordingly.
Hope this helps.
-- Daniel Currie
On 2004 Mar 01, at 11:39, Matt Jaffa wrote:
Hi,
I would like to delete a row from the NSTableView I have,
The NSTableView is wrapped within a NSScrollView as I think they are
normally within IB.
But I would like it when they select a Row to be deleted and then
press the
delete key for it to be removed.
How do I go about implementing something like this,
also to make it so that the cells in the NSTableView are not
selectable?
Just the rows as a whole to be selectable?
Thanks,
Matt
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.