Advertise Mobile SDKs Books Events Forum News Social Networking Support Us
Follow @iphonedevsdk on Twitter

Interface 2, Advanced iOS
Mockup & Code Gen
($9.99)

Make your own iPhone apps
and run them live!
(free)

Pic Frame Dynamo: Photo Editing
($0.99)

Abiliator
($1.99)

Want your application or service advertised on iPhone Dev SDK?

Go Back   iPhone Dev SDK Forum > Mac OS X Development Forums > Mac OS X Development

Reply
 
LinkBack Thread Tools Display Modes
Old 10-10-2011, 12:47 PM   #1 (permalink)
Registered Member
 
Join Date: Mar 2011
Posts: 9
kwackers is on a distinguished road
Default How do I detect when my app loses focus (to widget screen)?

Hi guys,

thanks for reading this. I'm new to mac development and have tried writing a simple game (running under Lion).
I can detect and pause my game when it loses focus by clicking on something else, but not when swiping to the widget screen (my game continues to run).

I've looked through all the application and window notifications but haven't found anything that helps (perhaps I'm looking in the wrong place?).

I guess there must be some form of notification that tells you that you've lost focus after the user moves to the widget screen but I'm at a loss as to what it may be.

Does anyone have any pointers to a solution?

Thanks, Steve.
kwackers is offline   Reply With Quote
Old 10-10-2011, 01:14 PM   #2 (permalink)
Registered Member
 
Join Date: Jan 2010
Posts: 342
flamingliquid is on a distinguished road
Default

Just for your knowledge, the widget screen is formally known as the Dashboard, just to help you find answers in the future

I just did a quick test and
Code:
- (void)applicationDidResignActive:(NSNotification *)aNotification
is called when I swipe to the Dashboard. Is this working for you?
__________________
17 year old nerd.
Send me a PM. Maybe I can help.
flamingliquid is offline   Reply With Quote
Old 10-10-2011, 02:27 PM   #3 (permalink)
Registered Member
 
Join Date: Mar 2011
Posts: 9
kwackers is on a distinguished road
Default

Quote:
Originally Posted by flamingliquid View Post
Just for your knowledge, the widget screen is formally known as the Dashboard, just to help you find answers in the future

I just did a quick test and
Code:
- (void)applicationDidResignActive:(NSNotification *)aNotification
is called when I swipe to the Dashboard. Is this working for you?
Hi and thanks for taking the time to answer.
I didn't realise that was the dashboard... (What's the screen called when you do a 3 fingered wipe vertically on the trackpad and see all the windows? I don't get any notifications for that either - my game carries on inside a thumbnail...)

Anyway I tried adding that function to my code and nothing happens, I've also tried setting a notification explicitly (is just adding the function all I need?) like below:
Code:
[[NSNotificationCenter defaultCenter] addObserver:self 
                                                 selector:@selector(PauseGame) 
                                                     name:NSApplicationDidHideNotification
                                                   object:self];
I also set various other notifications in the same block of code and they all seem to work fine (i.e. NSViewGlobalFrameDidChangeNotification).
Perhaps there's something else I need to do?
kwackers is offline   Reply With Quote
Reply

Bookmarks

Tags
detecting, lion, notifications, widget

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



» Advertisements
» Online Users: 371
9 members and 362 guests
Creativ, Emy, husthlj, illogical, LegionMD, LunarMoon, padsoftware, stanny, VinceYuan
Most users ever online was 1,387, 04-10-2012 at 04:21 AM.
» Stats
Members: 175,677
Threads: 94,127
Posts: 402,916
Top Poster: BrianSlick (7,990)
Welcome to our newest member, husthlj
Powered by vBadvanced CMPS v3.1.0

All times are GMT -5. The time now is 07:17 AM.
Powered by vBulletin® Version 3.8.0
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.3.0