Mailing Lists: Apple Mailing Lists

Image of Mac OS face in stamp
 
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Overriding the new inter-cell navigation of NSTableView



Subject: Overriding the new inter-cell navigation of NSTableView

Hi!
In my app I need to be able to have the return, enter or down arrow key
give focus to the cell that is under the current one and begin editing,
to edit sequentially the same attribute of multiple objects.
What is the best way of doing this?
Thanks,
Flofl.

I found that the keyDown: + interpretKeyEvents method wouldn't work with the NSTextFieldCell so I ended up overriding endEditing: (tv is an outlet to the parent tableView of the cell):


- (void)endEditing:(NSText *)textObj {

   int editedRow = [tv editedRow];
   int editedColumn = [tv editedColumn];
   int numberOfRows = [tv numberOfRows];

editedRow ++;
editedRow = (editedRow == numberOfRows ? 0 : editedRow); // Selects the first row when the las one is reached.


   [super endEditing:textObj];

   // Select the row (needed to avoid an exception to be raised).
   [tv selectRow:editedRow byExtendingSelection:NO];

   [tv editColumn:editedColumn
	       row:editedRow
	 withEvent:nil
	    select:YES];
}

It works, but is it the best way? It looks more like a workaround than like the regular way of customizing "the tab-loop behavior"... And what if I want to take different actions according to the key that ended the editing?

Flofl.
_______________________________________________

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:
http://lists.apple.com/mailman/options/cocoa-dev/email@hidden

This email sent to email@hidden


Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2007 Apple Inc. All rights reserved.