Re: NSTableView rows and delete key
Re: NSTableView rows and delete key
- Subject: Re: NSTableView rows and delete key
- From: Brian Webster <email@hidden>
- Date: Thu, 25 Jul 2002 17:17:22 -0500
On Thursday, July 25, 2002, at 04:20 PM, cocoa-dev-
email@hidden wrote:
I read the 'deleting multiple rows' topic on the list, but what I need
is more essential :
Do I just need to activate this as an option ?
Do I need to receive a delegation/notification ? (I don't want
to create
a 'delete' NSButton, which would be very easy, of course); I cannot
find any delegation/notification about key pressed.
The short answer is that no such delegate method exists for NSTableView.
Delegate methods are provided for the tasks that the designers
of the class think will be the most commonly used. If enough
people implement a particular feature and request it as being
rolled into the framework, then a new delegate method can be
added. An example of this is the drag and drop methods for
NSTableView, which did not exist before 10.0. If you want the
feature, give Apple feedback, and if enough people want it,
they'll add it (eventually).
Do I really need to subclass NSTableView to do so ? (for such a basic
feature ?)
Yes. This is an interesting progression I see a lot of people
go through from learning Cocoa. If they've done programming in
another environment and are used to subclassing things to add
functionality, they're like "whaddya mean I don't subclass!?".
Then, after they get used to delegates and the like, when
something comes up that requires a subclass, even if it's only
one method, then they're like "whaddya mean I have to
subclass?!". Just an observation I've made. Subclassing's
really not the end of the world, although you still generally
try to avoid it if possible.
If necessary, can I know if the table view is the current active key
view ?
Yes: if([[myTableView window] firstResponder] == myTableView)...
Finally, a philosophical question : is there always a lot of ways to do
a single thing in Cocoa (as in Perl, for example), or are there cases
where there is only one possible way ?
There's often more than one way to go about most things, but
it's usually the case that one way is a whole lot more flexible
and/or convenient than the others. Part of the trick of
learning Cocoa is learning where to put your code so that it can
be leveraged the most effectively.
--
Brian Webster
email@hidden
http://homepage.mac.com/bwebster
_______________________________________________
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.