Re: Toddler-proofing an app: selectively disabling function keys?
Re: Toddler-proofing an app: selectively disabling function keys?
- Subject: Re: Toddler-proofing an app: selectively disabling function keys?
- From: Clay Heaton <email@hidden>
- Date: Mon, 24 Sep 2012 10:05:41 -0400
As I reported yesterday, I had luck with your second suggestion. There are a few minor problems that I would like to fix, discovered as my daughter banged on the keyboard this morning. These are the mappings on an extended keyboard:
- F1, F2 - the brightness keys - I would like to disable them while my app is running so that my daughter can't turn the screen off by mistake. I can shoehorn in this approach, if necessary, to keep brightness at its original level: <http://stackoverflow.com/questions/3239749/programmatically-change-mac-display-brightness>
- F4 - the Launchpad key - shows the Launchpad. Clicking an icon there launches the other app and makes it key. To me that seems like a bug with NSApplicationPresentationDisableProcessSwitching
- F7, F8, F8 - iTunes keys - these control iTunes in the background while my app is full screen and key. I would like to disable these while my app is running to prevent music from playing by accident.
I can intercept keystrokes on keys that aren't bound to another function, such as F5 and F6. My application doesn't even register keystrokes on the keys that are bound to other functions, however. Is there any way to capture these keystrokes and/or prevent the bound actions from occurring when they are pressed?
Thanks,
Clay
On Sep 22, 2012, at 2:59 AM, Ken Thomases <email@hidden> wrote:
>
> If your app is full-screen, you might capture the display. See the Quartz Display Services <https://developer.apple.com/library/mac/#documentation/graphicsimaging/Conceptual/QuartzDisplayServicesConceptual/Articles/DisplayCapture.html>. Capturing the display prevents Command-Tab app switching, Exposé/Mission Control, Spotlight, etc. I believe it will also prevent system keyboard shortcuts (e.g. hiding the Dock with Command-Option-D) from reaching the wider system.
>
> It might also work to set the application presentation options. -[NSApplication setPresentationOptions:] with options including NSApplicationPresentationDisableAppleMenu and NSApplicationPresentationDisableProcessSwitching. Or those options can be included with the options passed to -[NSView enterFullScreenMode:withOptions:] under the NSFullScreenModeApplicationPresentationOptions key.
>
> Finally, you can use a custom subclass of NSApplication, override -sendEvent:, detect events which correspond to hot keys, and don't pass them through to super. Detecting hot keys is kind of hard. There's CopySymbolicHotKeys(), but it can be hard to interpret the output data and it's probably also not available in 64-bit. For a private-use-only app, you can get away with hard-coding keys that actually cause you trouble.
>
> 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