Welcome to the MacNN Forums.

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

You are here: MacNN Forums > Software - Troubleshooting and Discussion > Developer Center > action method for dock icon click...

action method for dock icon click...
Thread Tools
stupidFish23
Forum Regular
Join Date: Jan 2002
Location: Hungary
Status: Offline
Reply With Quote
Apr 19, 2002, 03:48 AM
 
Hi!

Is there an action method I could use to have my cocoa app perform whenever the user activates the app by clicking on its icon in the dock, if the app had been in the background before ?

nothing is when everything is alright
[email protected] ICQ: 153647416
     
Apocalypse
Dedicated MacNNer
Join Date: Jun 2000
Location: Dundas, Ontario, Canada
Status: Offline
Reply With Quote
Apr 19, 2002, 12:54 PM
 
If you delegate NSApp to one of your controller objects you could override the method:
- (void)applicationDidBecomeActive NSNotification *)aNotification

From there you could check to see if any of the windows just received a mouse event (note that this would be trivial but tedious) and, if not, you can be pretty sure that they clicked on the dock icon.

I haven't tried it but it sounds logical.


edit:
After another look at the docs I found this method which might be better:
- (BOOL)applicationShouldHandleReopen NSApplication *)theApplication hasVisibleWindows BOOL)flag

This one is called whenever an already open program is double-clicked or whenever someone activates it with the dock. This might work better
/edit

Hope that helps,
Jeff.

[ 04-19-2002: Message edited by: Apocalypse ]
Spectral Class
"Shedding Light on Innovation"
     
stupidFish23  (op)
Forum Regular
Join Date: Jan 2002
Location: Hungary
Status: Offline
Reply With Quote
Apr 19, 2002, 01:26 PM
 
thanks, Apocalypse, i'll try it out and tell you how it went.

PS: where did you get your nickname from?

nothing is when everything is alright
[email protected] ICQ: 153647416
     
stupidFish23  (op)
Forum Regular
Join Date: Jan 2002
Location: Hungary
Status: Offline
Reply With Quote
Apr 19, 2002, 02:22 PM
 
hmm.. i got stuck... i just can't get it to work... i just can't figure out how to use it. anyone help, please..
nothing is when everything is alright
[email protected] ICQ: 153647416
     
   
 
Forum Links
Forum 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
Top
Privacy Policy
All times are GMT -4. The time now is 09:28 AM.
All contents of these forums © 1995-2017 MacNN. All rights reserved.
Branding + Design: www.gesamtbild.com
vBulletin v.3.8.8 © 2000-2017, Jelsoft Enterprises Ltd.,