Re: How do I use CGDisplayCapture() to capture an NSOpenGLView in a XIB?
Re: How do I use CGDisplayCapture() to capture an NSOpenGLView in a XIB?
- Subject: Re: How do I use CGDisplayCapture() to capture an NSOpenGLView in a XIB?
- From: Clay Heaton <email@hidden>
- Date: Tue, 22 Jan 2013 21:33:49 -0500
Thanks, Ken.
I read the docs more carefully and looked at the full screen demo projects. As you mentioned, my understanding is that -enterFullScreenMode:withOptions: should capture the screen as long as NSFullScreenModeApplicationPresentationOptions is not present. That is confirmed in the NSView documents for the -enterFullScreenMode:withOptions:.
Looking at the CoreAnimationKioskStyleMenu sample project, there's this bit of code:
// go full screen, as a kiosk application
[self enterFullScreenMode:[self.window screen] withOptions:NULL];
While that goes full screen and does prevent process switching, it still allows the iTunes function keys to pass through to the system (as well as the volume controls). Pressing F8 (play/pause) launches iTunes and causes music to play.
I would like to intercept all key presses and only send the volume control keys through to the system.
Things I have tried include:
- subclassing NSApplication and overriding - sendEvent: to capture all keys. The iTunes keys still pass through, though nothing else does.
- capturing the display with
...
CGDirectDisplayID display = kCGDirectMainDisplay;
CGError err = CGCaptureAllDisplaysWithOptions(kCGCaptureNoFill);
...
- capturing the display with -enterFullScreenMode:withOptions:
- reading your posts from here http://www.cocoabuilder.com/archive/cocoa/231645-disabling-key-bindings.html
I'm at a loss - is there any way to intercept and disable the iTunes function keys?
Thanks,
Clay
On Jan 22, 2013, at 7:17 PM, Ken Thomases <email@hidden> wrote:
>
> On Jan 22, 2013, at 10:16 AM, Clay Heaton wrote:
>
>> That's actually what I'm doing at the moment:
>>
>> NSApplicationPresentationOptions options = NSApplicationPresentationHideDock + NSApplicationPresentationDisableProcessSwitching + NSApplicationPresentationHideMenuBar;
>> NSNumber *presentationOptions = [NSNumber numberWithUnsignedLong:options];
>> NSArray *keys = [NSArray arrayWithObjects:@"NSFullScreenModeAllScreens", @"NSFullScreenModeApplicationPresentationOptions", nil];
>> NSArray *values = [NSArray arrayWithObjects:[NSNumber numberWithBool:YES], presentationOptions, nil];
>> NSDictionary *fullScreenOptions = [[NSDictionary alloc] initWithObjects:values forKeys:keys];
>>
>> [glView_ enterFullScreenMode:[NSScreen mainScreen] withOptions:fullScreenOptions];
>>
>> There are a few problems:
>> - The F4 key still allows process switching (Kiosk mode bug with NSApplicationPresentationDisableProcessSwitching; radar ID 12358575)
>> - The function keys still pass through to the system (iTunes, brightness, etc.)
>>
>> The application is for toddlers (https://itunes.apple.com/us/app/toddler-typer/id566326332?mt=12). Several months of use and feedback show that they find and find joy from pressing the keys that pass through to the system. Since I'm trying to create an environment where they won't mess up anything on the computer, I don't really want them switching processes, etc.
>
> Given that you're using -enterFullScreenMode:withOptions: and you do want to capture the screen, you should leave out NSFullScreenModeApplicationPresentationOptions. The options that you're passing are all implicit in capturing the display anyway.
>
> Also, NSFullScreenModeApplicationPresentationOptions and NSFullScreenModeAllScreens are identifiers. You should use them as such, not as the contents of strings. (I don't know if the value of the string values named by those identifiers happens to match the identifiers themselves. Even if they do, you shouldn't rely on that.)
>
> Cheers,
> Ken
>
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden