Accessing "current document" when not the frontmost application
Accessing "current document" when not the frontmost application
- Subject: Accessing "current document" when not the frontmost application
- From: Kirk Kerekes <email@hidden>
- Date: Wed, 31 Jul 2002 21:20:09 -0500
I am tring to implement a system service in my doc-app, and have had little
difficulty with the normal stumbling-blocks...
(although I feel compelled to opine that the "expert" info.plist editor
integral to Project Builder S**KS REALLY BADLY and there appears to be no
sane way to get around using it if you implement services in the manner
that Apple specifies)
Anyway, the stumbling-block that I have hit is that when my application is
_not_ the frontmost app, and is the "target" of a System Services call,
calling:
[[NSDocumentController sharedDocumentController] currentDocument];
returns nil instead of the (very real) current document. Presumably this is
because currentDocument probably uses [NSApplication mainWindow], which has
an interesting set of qualifiers:
This method returns nil if there is no main window, if the application's
nib file hasn't finished loading, if the main window belongs to another
application, or if the application is hidden.
It appears that when my application gets a service request (somebody)
brings its _windows_ to the front without bringing the _application_ to the
front -- thus, the windows now "belong to another application". Or
something. Or maybe not being the frontmost app counts as "hidden".
While I could probably brute-force this in some manner, I am looking for
guidance as to the slick, straightforward cocoa-ish method that will let my
app find its own current document (the frontmost document in the app's
document set), so that it can continue with the service request -- ideally
without needing to come to the front.
I would have happily researched this on mamasam.com, but it appears to be
down at the moment -- making it painfully apparent to me just how essential
it has become.
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.