• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Accessing "current document" when not the frontmost application
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Accessing "current document" when not the frontmost application


  • Subject: Re: Accessing "current document" when not the frontmost application
  • From: Kirk Kerekes <email@hidden>
  • Date: Thu, 1 Aug 2002 10:48:56 -0500

I haven't been idle on this, when Mamasam came back up, I searched it and concluded that I should be using the responder chain.

Except that it doesn't work (at least with action messages) when the app isn't "active" either.

[NSApp sendAction:@selector(frontDoc:) to:nil from:self] always return nil when the app is not in front, and works just fine when the app is "active"
.

(and activating the app doesn't seem practical either -- it appears to take a full cycle through the event loop to get that job done. On return from [NSApp activateIgnoringOtherApps:YES], the app is NOT active -- just about-to-be-active).

Must I create my own document tracking, just so I can make a document-targeted service work?

The sticking point here is that I need to be able to provide a meaningful error return value (if appropriate) from my service routine.



On Thursday, August 1, 2002, at 12:04 AM, email@hidden wrote:

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.

  • Prev by Date: subclassing NSMutableArray
  • Next by Date: Re: NSBezierPath
  • Previous by thread: Re: subclassing NSMutableArray
  • Next by thread: Re: Better way to replace a character in a string?
  • Index(es):
    • Date
    • Thread