Re: How to make NSImageView respond to keyboard events?
Re: How to make NSImageView respond to keyboard events?
- Subject: Re: How to make NSImageView respond to keyboard events?
- From: matt neuburg <email@hidden>
- Date: Fri, 14 May 2004 09:32:03 -0700
On Thu, 13 May 2004 23:25:57 +0200, Laurent Bertacchini
<email@hidden> said:
>
I'm writing a small picture viewer, and I use a subclass of NSImageView
>
to display the pictures. Everything works fine except that on some
>
occasions (ex. full screen, ...) I'd like it to respond to keyboard
>
events. I tried overriding - (BOOL)acceptsFirstResponder, -
>
(BOOL)becomeFirstResponder, and - (BOOL)resignFirstResponder, so that
>
they return YES, but it doesn't seem to be enough (I only get a beep
>
when I press a key). I know that if I pass YES to setEditable, the
>
keyboard events will be parsed, but it will also trigger the drag &
>
drop feature, and I don't want that.
>
So, any ideas?
On my machine, using an NSImageView subclass in a project where this is the
only code in the entire project, this works just fine:
#import "MyImageView.h"
@implementation MyImageView
- (void)keyDown:(NSEvent *)theEvent {
NSLog(@"here"); // this works
}
@end
This suggests that the ...FirstResponder stuff is a red herring. Perhaps
you've merely forgotten to set the image view in Interface Builder to be
your subclass...? m.
--
matt neuburg, phd = email@hidden,
http://www.tidbits.com/matt/
pantes anthropoi tou eidenai oregontai phusei
AppleScript: the Definitive Guide! NOW SHIPPING...! (Finally.)
http://www.amazon.com/exec/obidos/ASIN/0596005571/somethingsbymatt
Subscribe to TidBITS! It's free and smart.
http://www.tidbits.com/
_______________________________________________
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.