Re: Capturing keydown events in an NSImageView?
Re: Capturing keydown events in an NSImageView?
- Subject: Re: Capturing keydown events in an NSImageView?
- From: Jerry LeVan <email@hidden>
- Date: Fri, 25 Jun 2004 13:24:21 -0400
Bless You Kind Sir :)
I owe you a virtual Beer...
I have been reading the fine manual but code not find the magical
incantation.
Jerry
On Jun 25, 2004, at 1:14 PM, Brent Gulanowski wrote:
On Fri, 25 Jun 2004 11:55:10 -0400, Jerry LeVan <email@hidden>
wrote:
Hello,
I am trying to capture keydown events for an ImageView.
I have subclassed NSImageView ....
--------
#import <Cocoa/Cocoa.h>
@interface KeyImageView : NSImageView
{
IBOutlet id theController; // provides access to main controller
object
}
-(BOOL)acceptsFirstResponder;
-(BOOL)resignFirstResponder;
-(BOOL)becomeFirstResponder;
-(void)keyDown:(NSEvent*)theEvent;
@end
-------------
#import "KeyImageView.h"
@implementation KeyImageView
-(BOOL)acceptsFirstResponder
{
NSLog(@"Accepting First Responder");
return YES;
}
-(BOOL)resignFirstResponder
{
NSLog(@"Resigned First Responder");
return YES;
}
-(BOOL)becomeFirstResponder
{
NSLog(@"Become First Responder");
}
-(void)keyDown:(NSEvent*)theEvent
{
NSLog(@"Key down: %@",theEvent);
}
@end
--------
The only message I get on the console is the Accept message
the Become message never fires and key strokes always get
the "bell".
What am I missing here?
Thanks,
Jerry
_______________________________________________
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.
That's all good, but you also have to make that view the first
responder. I haven't dealt with this question in two years, but then I
had to send the window a makeFirstResponder: message with the view as
the argument. There's an outlet for first responder in NSWindow and
you can connect it in IB, but I don't remember that doing what I
wanted.
You can tell if your view is not getting set as first responder if the
behaviour you want happens after you click the view with the mouse.
Cheers,
Brent
_______________________________________________
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.