• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Overriding the new inter-cell navigation of NSTableView
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Overriding the new inter-cell navigation of NSTableView


  • Subject: Re: Overriding the new inter-cell navigation of NSTableView
  • From: Wdyp <email@hidden>
  • Date: Sat, 1 Dec 2007 08:03:16 +0100

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:
This email sent to email@hidden


  • Prev by Date: Re: Creating subviews programmatically ?
  • Next by Date: [ANN] New version of RegexKit available
  • Previous by thread: Overriding the new inter-cell navigation of NSTableView
  • Next by thread: NSWindow styleMask warning on bit 0x10
  • Index(es):
    • Date
    • Thread