Re: NSTableView behavior changes
Re: NSTableView behavior changes
- Subject: Re: NSTableView behavior changes
- From: Graham Cox <email@hidden>
- Date: Wed, 18 Feb 2009 11:53:14 +1100
On 18 Feb 2009, at 11:37 am, Harry Plate wrote:
I am new to NSTableView (and to Cocoa for that matter) so excuse my
lame
questions.
I have an NSTableView doing what I want (kinda), but I want to
modify its
behavior, and I am at a loss as where to begin.
What I want is this:
1) to disable any possible editing of the "strings" in the table.
Right
now it kinda appears that I can select an entry, and edit it. But
for some
magical reason, the table defers to the original value. I like the
fact that
the value could not be changed, but would prefer that the user would
not get
into any editting mode.
In IB, select the table column, and uncheck 'editable'. This will
prevent the item getting into the editable state at all.
The reason your current edit changes don't 'stick' is because your
datasource isn't implementing -
tableView:setObjectValue:forTableColumn:row:
2) I would like my user to be able to select a table entry, and
be able
to respond to the 'delete' key - by discarding the selected entry.
Currently
that does not work at all.
You have to make this happen yourself. The controller that is handling
the tableview will need to respond to the delete key by finding the
current selection (i.e. calling -selectedRowIndexes on the tableview),
deleting the corresponding items from the data model and reloading the
table view.
To respond to the delete key, the controller will need to subclass
NSResponder and insert itself as the next responder to the table view
by calling [tableView setNextResponder:self]; . It then needs to
override -deleteBackward: or whatever.
Currently the reqd data source methods for NSTableView
(numberOfRowsInTableView: and
tableView:objectValueForTableColumn:row:) are
implemented in my controller class. So I assume that magically my
controller
has become the "data source" for the table view.
There's no such thing as magic ;-)
Yes the controller will typically be the datasource, but you have to
set this up, usually in IB by dragging a connection between the
table's 'datasource' outlet and the controller.
I have read something about a "field editor" - could this be the
clue to my
rquirements listed above?
Not really relevant at this stage.
--Graham
_______________________________________________
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