Note that there are some explanatory texts on larger screens.

plurals
  1. PONSView -(void)keyDown in console program
    text
    copied!<p>I'm not getting the -(void)keyDown callback on my inherited NSOpenGLView (note that mouseMoved does not work either though I do setAcceptsMouseMovedEvents:YES, but that is not an issue yet). It implements</p> <pre><code>- (BOOL)acceptsFirstResponder { return YES; } </code></pre> <p>but still no luck. My knowledgeable friend implied that it might have something to do with that the application is still a console application and not a bundled .app (I'm currently porting it). If so: is there some way to circumvent? Could the cause be something else? When I terminate my console application, I frequently see all my keypresses go to stdout so it does seem reasonable...</p> <p><strong>Edit:</strong></p> <pre><code>@implementation UiMacApplication - (void)run { } - (void)terminate:(id)sender { ... } - (void)startDummyThread:(id)sender { printf("startDummyThread!\n"); } @end .... mApplication = (UiMacApplication*)[UiMacApplication sharedApplication]; [NSThread detachNewThreadSelector: @selector(startDummyThread:) toTarget: mApplication withObject: nil]; [[NSNotificationCenter defaultCenter] postNotificationName:NSApplicationWillFinishLaunchingNotification object: NSApp]; [[NSNotificationCenter defaultCenter] postNotificationName:NSApplicationDidFinishLaunchingNotification object: NSApp]; </code></pre> <p>Main loop:</p> <pre><code>NSEvent* event = [mApplication nextEventMatchingMask: NSAnyEventMask untilDate: nil inMode: NSDefaultRunLoopMode dequeue: YES]; [mApplication sendEvent: event]; [mApplication updateWindows]; </code></pre> <p><strong>Edit 2:</strong> Running through the console caused the problem. Simply converting it into a proper .app made it receive keyDown, keyUp and flagsChanged on the first attempt.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload