Re: a key down event problem
Re: a key down event problem
- Subject: Re: a key down event problem
- From: Christopher Corbell <email@hidden>
- Date: Tue, 27 May 2003 11:43:10 -0700
On Tuesday, May 27, 2003, at 08:53 AM, Fei Li wrote:
Hello all,
I have a strange problem with key down event.
I have a full screen window which need to receive esc key event to
terminate the application. I use:
- (BOOL)canBecomeKeyWindow
{
return YES;
}
- (BOOL)canBecomeMainWindow
{
return YES;
}
-(void)keyDown:(NSEvent *)theEvent
{
unsigned short theKey;
theKey = [theEvent keyCode];
if (theKey == 53) //ESC key
{
[NSApp terminate:self];
}
}
in my window class. This works fine on MacOSX 10.1, but doesn't work on
MacOSX 10.2. The more strange thing is, on MacOSX 10.2, this also works
fine when I select Build & Run or Run Executable in ProjectBuilder, but
if I run it from finder window, my keyDown function will not be fired
(as I put a NSLog message in keyDown and it doesn't appear in console).
I'm really confused. If anyone have any idea about it?
Thanks for any information!
Fei
Just a hunch, you might try sending an explicit [ makeKeyAndOrderFront]
message to your window when it's shown (in awakeFromNib or someplace
similar). It may be that when you run from ProjectBuilder there's a
code path
that does this for you (because of the app context switch), but when you
launch from the Finder the message never happens.
hth,
Christopher
_______________________________________________
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.