Re: NSTableView rows and delete key
Re: NSTableView rows and delete key
- Subject: Re: NSTableView rows and delete key
- From: Raphaël Delcroix <email@hidden>
- Date: Mon, 29 Jul 2002 11:23:00 +0200
This has consequences, which might or might not be desirable in your
application. For example:
[...]
wow ! terrific !
That gives me a very more precise comprehension of the problem. I
recognized the style and the spirit of the Vermont Recipes, which
sincerely is the best introduction to Cocoa programming I have ever read.
5. In general, writing a category method to replace an existing Cocoa
method
is risky. You don't know how the built-in Cocoa method was implemented,
such
as what interdependencies it may have with other parts of Cocoa. Did the
built-in method set a flag somewhere in the text system? Did the
built-in
method consult a flag somewhere in the drawing system? You can't know
for
sure. You can consult the documentation and you can test your
application as
long as you like, but ultimately you are left to guess whether your
category
method might encounter an unexpected problem someday. (Writing a
category
method to add a new capability to an existing class is much safer.)
This gives a very clear and simple rule.
Besides, is it possible to have the Cocoa framework sources ?
I cannot see anything more instructive than analysing the framework; it
allows a complete comprehension of what we do, and gives an official
model for writing classes.
- (void)keyDown:(NSEvent *)event {
unichar key = [[event charactersIgnoringModifiers]
characterAtIndex:0];
unsigned int flags = [event modifierFlags];
if (key == NSDeleteCharacter && flags == 0 && [self numberOfRows] >
0 &&
[self selectedRow] != -1) {
[[[self window] windowController]
deleteAntiqueRecordAction:self];
} else {
[super keyDown:event]; // let somebody else handle the event
}
}
That IS the example I was looking for, especially for the NSEvent use.
Sometimes I feel the Cocoa documentation lacks (simple) examples like
that.
Thanks,
R.D.
_______________________________________________
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.