Re: Exit screen saver programmatically?
Re: Exit screen saver programmatically?
- Subject: Re: Exit screen saver programmatically?
- From: John Horigan <email@hidden>
- Date: Thu, 24 Sep 2009 06:57:33 -0700
If you send the unwanted events to ScreenSaverView parent of your view
then it should terminate gracefully.
[super theEvent];
-- john
On Sep 24, 2009, at 1:14 AM, Gabriel Zachmann wrote:
Post a mouse down event and the sceensaver engine will remove it
for you.
That is a good idea -- except I have no idea how to do that.
Could you give me a hint how to achieve that? (class / method names?)
(Sorry, for asking shuch a dumbquestion.)
BTW: just a mouse move event would suffice, is that possible, too?
(that way, I wouldn't have to worry about coordinates)
It's possible; you'd have to discriminate based on the bundle
identifier returned by the main NSBundle.
what exactly are you trying to accomplish?
I want to catch a few key events in my screen saver (like cursor
keys, space, return),
but if the user clicks any other key, I want the screen saver to
exit, just like other screen savers that don't catch any keyboard
events.
So, right now, I tried this:
if ( ! [self isPreview] )
[NSApp terminate: self];
but this has the disadvantage in the following scenario:
1. User opens System Preferences / Screen Saver, and activates my
screensaver
2. User clicks 'Test', my screen saver runs in full screen mode
3. User clicks any key (other than the few above mentioned ones)
Problem is: after that the System Preferences app is gone, too!
Currently, the complete key handling code in my screen saver looks
like this:
- (void) keyDown: (NSEvent *) theEvent
{
if ( [theEvent modifierFlags] & NSNumericPadKeyMask )
{
[self interpretKeyEvents: [NSArray arrayWithObject:theEvent] ];
}
else
{
// exit gracefully
if ( ! [self isPreview] )
[NSApp terminate: self];
}
}
- (IBAction) moveLeft: (id) sender
{
...
}
____________________________________________________________
Eigentlich bin ich ganz anders, nur komme ich so selten dazu.
( Ödön von Horváth )
____________________________________________________________
http://zach.in.tu-clausthal.de
____________________________________________________________
_______________________________________________
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