Mailing Lists: Apple Mailing Lists

Image of Mac OS face in stamp
 
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Open Handler, when is it called?



At 12:01 -0700 15/5/01, "Glenn L. Austin" <email@hidden> wrote:

Les R. Titze <email@hidden> wrote:

I had to work around this issue in my code to determine when to show a new
untitled document.

After thinking about it overnight (cook slowly...), I realize that my real
problem is that my application does two different things on startup. If a
document was double-clicked, it should just open the document. Otherwise, it
should show a login window.

The best way to determine whether the user double-clicked on the application
or a document is to add both an OpenDocument and OpenApplication handler.
You'll always get an OpenDocument from double-clicking a document, and
you'll always get an OpenApplication from double-clicking the application.

But can you guarantee that the OpenApplication handler *won't* be called if you start the application by double clicking a document, or at least that the OpenDocument handler will be called first? If not, that doesn't really help you.

What I do (essentially) is have the open document handler set a flag, and then after registering my open document handler (near the beginning of my main method) I then use SwingUtilities.invokeLater to delay a runnable that checks if the flag has been set or not. If it hasn't then I know to create a new blank document rather than opening an existing one. That seems to work quite well.

-Rolf
--
Rolf Howarth, Square Box Systems Ltd, Stratford-upon-Avon UK.

CatDV 1.5.3 - Power tools for logging and cataloguing digital video
The essential tool for video editors, available at http://www.catdv.com




Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2007 Apple Inc. All rights reserved.