• 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: NSTableView return key and editing
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: NSTableView return key and editing


  • Subject: Re: NSTableView return key and editing
  • From: Just van Rossum <email@hidden>
  • Date: Fri, 23 May 2003 11:20:11 +0200

Christopher Corbell wrote:

> How does one cleverly defeat the continuation of editing items
> that NSTableView implements with the return key?
>
> With an editable, single-column table, if you edit an item and
> hit return, NSTableView then automatically causes the item below
> it to become open for editing. I do not want this to happen, but
> trying to defeat it with from the delegate shouldEditTableColumn:
> doesn't work - if I say no, I get another editColumn: invocation;
> if I say no twice, I get a third! It won't give up.
>
> I've put in a one-shot timer that aborts editing after a short time
> but this seems like an inelegant solution.

Inelegant, yes, but the solution just posted by Christopher Corbell
seems even less elegant. I had good results by doing this (transcribed
from Python, so apologies for any ObjC mistakes):

- (void)tableView:(NSTableView*)tableView setObjectValue:(id)newObj
forTableColumn:(NSTableColumn*)col row:(int)row
{
...update model...
[self performSelector:forceEndEditing withObject:tableView
afterDelay: 0];
}

- (void)forceEndEditing:(NSTableView*)tableView
{
id window = [tableView window]
if ([window makeFirstResponder:tableView])
// should really select the edited row
[tableView deselectAll:self];
else
// last resort
[window endEditingFor:nil];
}

(That last bit is based on the example in
file:///Developer/Documentation/Cocoa/Reference/ApplicationKit/
ObjC_classic/Classes/NSWindow.html#//apple_ref/occ/instm/NSWindow/
endEditingFor:)

Just
_______________________________________________
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.

References: 
 >NSTableView return key and editing (From: Christopher Corbell <email@hidden>)

  • Prev by Date: Re: iTunes events?
  • Next by Date: Re: NSTableView return key and editing
  • Previous by thread: Re: NSTableView return key and editing
  • Next by thread: Re: NSTableView return key and editing
  • Index(es):
    • Date
    • Thread