[Pythonmac-SIG] How to tell if a .app is clicked again?

Nicholas Riley njriley at uiuc.edu
Tue Aug 16 22:11:49 CEST 2005

On Tue, Aug 16, 2005 at 09:51:57AM -1000, Bob Ippolito wrote:
> IIRC, on Mac OS X, there isn't a difference between "re-launching"  
> and becoming active.  Double-clicking the app should have the same  
> behavior as cmd-tabbing over to it (or using expos?, or the dock,  
> etc.), because LaunchServices recognizes that the application is  
> already open and just tells it to activate.

It used to be, back in System 7, but at some point (7.6? 8.0?) the
'aevt'/'rapp' (kAEReopenApplication) event was sent when an
application is double-clicked in the Finder and is already open.  The
same occurs when you click on the application's dock icon in OS X.

You can test this, for example, with TextEdit.  Open it, close the
untitled window, switch somewhere else, then cmd-tab to it: you don't
get an untitled window.  Then switch somewhere else and click on its
icon in the dock: you do get an untitled window.

> > Another issue: It puts an icon in the dock, but I don't have any
> > wxWindows or anything, so it doesn't do much. The only way I can
> > figure out how to stop it is to right click on the icon in the
> > dock and select force quit. I see two possible solutions:

It depends on the Web server you're using and how well it fits with
CF/NSRunLoop and friends.  Chris might be able to run a regular PyObjC
app (from which you can easily set up a NSApplication delegate to
implement applicationShouldHandleReopen_hasVisibleWindows_) and the
Web server in other threads, or not...

Nicholas Riley <njriley at uiuc.edu> | <http://www.uiuc.edu/ph/www/njriley>

More information about the Pythonmac-SIG mailing list