In the code below I am Initialising a NSViewController
[a NSResponder], with a NSWindow
, a NSOpenGLView
, presenting the view and attempting to set the NSViewController
as the windows first responder.
It is not working. I was expecting to be able to hit a breakpoint in the keyUp:
and keyDown:
methods also below, but nothing is happening.
Am I missing something?
-(void)initwithFrame:(CGRect)frame
{
window = [[MyNSWindow alloc] initWithContentRect:frame styleMask:NSClosableWindowMask | NSTitledWindowMask backing:NSBackingStoreBuffered defer: YES ];
OpenGLView* glView = [[[OpenGLView alloc] initWithFrame:window.frame] autorelease];
window.contentView = glView;
[window makeFirstResponder:self];
[window makeKeyWindow];
[window display];
}
-(void)keyDown:(NSEvent*)theEvent
{
unichar unicodeKey = [ [ theEvent characters ] characterAtIndex:0 ];
unicodeKey = 0;
}
-(void)keyUp:(NSEvent *)theEvent
{
unichar unicodeKey = [ [ theEvent characters ] characterAtIndex:0 ];
unicodeKey = 0;
}