I'm developing a kiosk mode application for OSX. In some circumstances, another screen gets attached. My application runs in fullscreen on one screen using:
[self.window.contentView enterFullScreenMode:s
withOptions:[NSDictionary dictionaryWithObject:appOptions
forKey:NSFullScreenModeApplicationPresentationOptions]];
The options are the following:
[NSNumber numberWithUnsignedInt:(NSApplicationPresentationHideMenuBar|
NSApplicationPresentationHideDock|
NSApplicationPresentationDisableHideApplication|
NSApplicationPresentationDisableProcessSwitching|
NSApplicationPresentationDisableAppleMenu)];
What I want is limit the mouse cursor to the screen where the game is running.
How can I accomplish that?
Add an NSTrackingArea to the screens you don't want the mouse entering. When you get notified that the mouse has entered the tracking area, use CGEventCreateMouseEvent and CGPostEvent to move the mouse back to a safe location, probably the nearest point on the main screen.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With