Re: ESC while editing NSOutlineView subclass
Re: ESC while editing NSOutlineView subclass
- Subject: Re: ESC while editing NSOutlineView subclass
- From: Kevin Gessner <email@hidden>
- Date: Thu, 23 Apr 2009 23:16:06 +0200
I've got this in MyEditorOutlineView, my NSOutlineView subclass.
- (void)keyDown:(NSEvent *)theEvent {
[super keyDown:theEvent];
NSLog(@"keyDown: %d", [theEvent keyCode]);
#define returnKeyCode 36
switch([theEvent keyCode]) {
case returnKeyCode:
if([[self delegate]
respondsToSelector:@selector(newSiblingInEditor:)]) {
[(NSObject<MyEditorOutlineViewDelegate> *)[self
delegate] newSiblingInEditor:self];
}
break;
}
}
But it's never called when there's an editing session.
-- Kevin
Kevin Gessner
http://kevingessner.com
email@hidden
On Apr 23, 2009, at 5:21 PM, Corbin Dunn wrote:
The easiest way to do this is to just subclass tableview and
override keyDown:. IE:
- (void)keyDown:(NSEvent *)theEvent {
NSString *keyString = [theEvent charactersIgnoringModifiers];
unichar keyChar = ([keyString length]) > 0 ? [keyString
characterAtIndex:0] : 0;
BOOL handledKeyDown = NO;
NSInteger numRows = [self numberOfRows];
// check if keyChar is esc (27) and if so, -abortEditing (if you are
editing)
corbin
On Apr 23, 2009, at 6:04 AM, Kevin Gessner wrote:
Hello list,
I've created a subclass of NSOutlineView, MyEditorOutlineView
(implements only textDidEndEditing: and keyDown:). When a row is
being edited, I'd like the escape key to stop editing. I'm having
trouble working with the field editor.
I implemented - (BOOL)control:(NSControl *)control textView:
(NSTextView *)textView doCommandBySelector:(SEL)command in
MyEditorOutlineView, thinking that the outline view would be the
field editor's delegate, and so this method would be called. It's
not called. I'm unsure how to check the field editor's delegate, or
if I'm even on the right track.
I was also thinking about returning a custom field editor for
instances of MyEditorOutlineView, and having the field editor
handle ESC itself. This seems like overkill with all the delegate
methods available, though.
Thanks in advance for any help.
-- Kevin
Kevin Gessner
http://kevingessner.com
email@hidden
_______________________________________________
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