Re: Toddler-proofing an app (disabling spotlight keyboard shortcut)?

2012-09-23 Thread Clay Heaton
Thank you, Ken. Your tips pointed me in an acceptable direction. I poked around 
in the cocos2d internals and discovered that your second option worked best. 
The Kiosk Mode Technical Note was helpful:
http://developer.apple.com/library/mac/#technotes/KioskMode/Introduction/Introduction.html

This is the code that did it for me:

NSApplicationPresentationOptions options = NSApplicationPresentationHideDock + 
NSApplicationPresentationDisableProcessSwitching;
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];

I'll let my daughter bang on it tomorrow and we'll see what other sorts of 
secret key commands she discovers!

Cheers,
Clay


On Sep 22, 2012, at 2:59 AM, Ken Thomases k...@codeweavers.com 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 (Cocoa-dev@lists.apple.com)

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:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Re: Toddler-proofing an app (disabling spotlight keyboard shortcut)?

2012-09-22 Thread Ken Thomases
On Sep 21, 2012, at 9:39 AM, Clay Heaton wrote:

 My 20 month old daughter loves to bang on the keys of the keyboard. I made
 a simple cocos2d app that shows random animal pictures (with noises) when
 she presses keys. (This has proved very popular with her and she now can
 identify all of the animals!)
 
 Anyhow, she'll sit on my lap and bang the keyboard for 4-5 minutes at a
 time. The problem is that she very often hits command-space and then other
 keys, causing the app to exit full screen and Spotlight to activate. From
 time to time, she does other things, such as hiding the dock (in the
 background), switching spaces, etc.
 
 Is there a way for me to disable some of these system-level keyboard
 commands when the app that I made  has focus? I came across some old
 Carbon, namely:
 
 void *oldHotKeyMode = PushSymbolicHotKeyMode(kHIHotKeyModeAllDisabled);
 ...
 PopSymbolicHotKeyMode(oldHotKeyMode);
 
 but I run into compiler errors when I try to use these:
 
 ld: symbol(s) not found for architecture x86_64
 
 I'm using Xcode 4.5 and would like to continue using ARC if possible (since
 GC is depreciated).
 
 Any ideas?

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 (Cocoa-dev@lists.apple.com)

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:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Toddler-proofing an app (disabling spotlight keyboard shortcut)?

2012-09-21 Thread Clay Heaton
My 20 month old daughter loves to bang on the keys of the keyboard. I made
a simple cocos2d app that shows random animal pictures (with noises) when
she presses keys. (This has proved very popular with her and she now can
identify all of the animals!)

Anyhow, she'll sit on my lap and bang the keyboard for 4-5 minutes at a
time. The problem is that she very often hits command-space and then other
keys, causing the app to exit full screen and Spotlight to activate. From
time to time, she does other things, such as hiding the dock (in the
background), switching spaces, etc.

Is there a way for me to disable some of these system-level keyboard
commands when the app that I made  has focus? I came across some old
Carbon, namely:

void *oldHotKeyMode = PushSymbolicHotKeyMode(kHIHotKeyModeAllDisabled);
...
PopSymbolicHotKeyMode(oldHotKeyMode);

but I run into compiler errors when I try to use these:

ld: symbol(s) not found for architecture x86_64

I'm using Xcode 4.5 and would like to continue using ARC if possible (since
GC is depreciated).

Any ideas?
___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com