• 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
is this proper form? (solution to trapping enter on table view)
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

is this proper form? (solution to trapping enter on table view)


  • Subject: is this proper form? (solution to trapping enter on table view)
  • From: James Gregurich <email@hidden>
  • Date: Fri, 22 Mar 2002 09:32:56 -0600

Well, got no response to this on the omni list. perhaps I should try here...



here is my solution to redefining the enter key on a tab view so that it simply saves the changes instead of advancing to the next row. Is this solution a quality solution or are there any "gotchas" that aren't obvious to the newbie? I also trap the escape key to cancel a change.






in the table view delegate:

- (BOOL)control:(NSControl *)control textView:(NSTextView *)textView doCommandBySelector:(SEL)command
{

if ( [textView methodForSelector:command] == [textView methodForSelector:@selector(insertNewline:)] ) //trap enter
{

[[control window] makeFirstResponder:control]; //save current line

return TRUE;

}
else if ( [[control window] methodForSelector:command] == [[control window] methodForSelector:@selector(_cancelKey:)] ) //trap esc
{

[control abortEditing]; //abort editing

return TRUE;

}
else
{

return FALSE;

}


}


this solution seems to work well and is much simpler than others I have seen.


thanks,
James Gregurich
_______________________________________________
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.

  • Prev by Date: Re: Open Recent menu in non-doc app
  • Next by Date: dd: Cocoa for a living? [WAS: Cocoa's popularity]
  • Previous by thread: Re: looking for a developer
  • Next by thread: dd: Cocoa for a living? [WAS: Cocoa's popularity]
  • Index(es):
    • Date
    • Thread