is this proper form? (solution to trapping enter on table view)
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.