On Tue, 17 Mar 2009 17:00:54 -0700, Harry Plate <ha...@plate.net> said:
>Graham,
>
>Finally getting back to this problem.
>
>>>    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.
>
>So far I have tried to accomplish this without success.
>
>1) I defined my controller class:
>    @interface MCController : NSResponder
>
>2) I then defined (void)deleteBackward:(id)
>
>3) in -awakeFromNib, I set my controller as 1st responder:
>
>    [sourceTableView setNextResponder:self]

Instead of 2, define keyDown and check to see if ([[theEvent characters]
isEqualToString: @"\177"]).

Also be careful in (3); this is a linked list, so when you insert yourself
into the chain you are responsible for not breaking it.

Furthermore, you probably don't want to be the table view's responder,
because now you are between the table view and its scroll view. You probably
want to be the scroll view's responder. So:

    NSResponder* r = [[sourceTableView enclosingScrollView] nextResponder];
    [[sourceTableView enclosingScrollView] setNextResponder: self];
    [self setNextResponder: r];

Finally, make sure everything is getting hooked up and instantiated
correctly.

m.

-- 
matt neuburg, phd = m...@tidbits.com, <http://www.tidbits.com/matt/>
A fool + a tool + an autorelease pool = cool!
AppleScript: the Definitive Guide - Second Edition!
http://www.tidbits.com/matt/default.html#applescriptthings



_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to