-keyDown and Category problem
-keyDown and Category problem
- Subject: -keyDown and Category problem
- From: Yuki Nishida <email@hidden>
- Date: Sat, 22 May 2004 13:06:06 -0400
Hi,
I am trying to make my application receives keyDown events as well as
key-equivalents such as Command-D (my custom action).
I did a search in the archives and one post suggested that I add a
category to NSWindow, with the method -keyDown, like this:
@implementation NSWindow (MyEvents)
- (void)keyDown: (NSEvent *)event
{
unichar unicodeKey;
unicodeKey = [[event characters] characterAtIndex: 0];
switch(unicodeKey)
{
case NSUpArrowFunctionKey:
[[mainWindowController myView] rotateUp];
break;
// etc.
}
}
@end
But my problem is that I need access to my mainWindowController for the
openGLView, called myView,
which takes user input and performs actions. Since I can't add instance
variables to a category, how can I achieve this?
My former way of receiving keyDown events was to makeFirstResponder my
(I think it was) mainWindowController, and put
-keyDown in there. But then my Command-D menu action doesn't get
called, even though I do receive KeyDown events.
Either way, I'm stuck and could use your help.
Thanks,
-Yuki
_______________________________________________
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.