
它不起作用.我期待能够在keyUp:和keyDown:方法中遇到一个断点,但是没有发生任何事情.
我错过了什么吗?
-(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;}解决方法 回到这个问题,实际上问题出在其他地方. 我一直在使用这个睡眠功能来控制应用程序帧速率:
voID System::Sleep(double seconds){ NSDate* limit = [NSDate dateWithTimeIntervalSinceNow:seconds]; NSRunLooP* runLoop = [NSRunLoop currentRunLoop]; [runLoop runUntilDate:limit];} 这样做似乎完全冻结了系统并阻止了关键事件.
而是使用它来安排更新功能:
[NSTimer scheduledTimerWithTimeInterval:interval target:self selector:@selector(updateApp:) userInfo:nil repeats:YES];总结
以上是内存溢出为你收集整理的可可 – NSOpenGLView,NSWindow和NSResponder – makeFirstResponder不工作全部内容,希望文章能够帮你解决可可 – NSOpenGLView,NSWindow和NSResponder – makeFirstResponder不工作所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
微信扫一扫
支付宝扫一扫
评论列表(0条)