How do I get keyboard events in an NSScrollView?
How do I get keyboard events in an NSScrollView?
- Subject: How do I get keyboard events in an NSScrollView?
- From: Dave Riggle <email@hidden>
- Date: Wed, 20 Aug 2003 08:47:23 -0700
I have a custom NSMatrix class inside an NSScrollView inside an
NSWindow. How do I handle keyboard events such as Page Up, Page Down,
Home, End, and type-select? Whenever I type a key, my app just beeps.
I have linked my Window's initialFirstRepsonder to my NSScrollView. I
have overridden acceptsFirstResponder, resignsFirstResponder,
becomesFirstResponder, keyDown, pageDown, etc. in my NSMatrix subclass.
My acceptsFirstResponder gets called three times, but the other
routines are never called.
I also tried linking my Window's initialFirstResponder directly to my
NSMatrix subclass. In that case my acceptsFirstResponder gets called
once, but my other routines are still not called. I even tried calling
[[self window] makeFirstResponder: self] in my initWithFrame routine,
but that didn't make a difference either.
Any help would be greatly appreciated! I'm a Cocoa newbie, but I'm
already starting to lose my hair!
Also, why doesn't NSScrollView handle the basic page up/page
down/home/end functionality?
Dave
P.S. Here's my NSMatrix subclass code.
- (BOOL)acceptsFirstResponder
{
return YES;
}
- (BOOL)resignsFirstResponder
{
return YES;
}
- (BOOL)becomesFirstResponder
{
return YES;
}
- (void)keyDown:(NSEvent *)theEvent
{
NSLog([theEvent characters]);
}
- (void)pageDown:(NSEvent *)theEvent
{
NSLog(@"page down");
}
_______________________________________________
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.