• 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
NSApplication's Apple Event Handling
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

NSApplication's Apple Event Handling


  • Subject: NSApplication's Apple Event Handling
  • From: Scott Thompson <email@hidden>
  • Date: Tue, 28 Jun 2005 09:46:33 -0500

We've got this odd problem related to the way NSApplication handles Apple Events and I would like some guidance on tracking the problem down.

I have a document based application to which I am adding scripting support. The problem I am seeing relates strictly to the "open" and "close" events. I have NOT added any special handling for these events. They come "for free" with the Cocoa framework.

With the application I execute a script along the lines of:

tell application "MyApp"
    open "<path to document>"
 end tell.

this works fine.  The computer calls

[NSDocumentController openDocumentWithContentsOfURL:display:error:]

which eventually leads to my document class being created and filed in. Since this appears to be the first non-private method called when the Apple Event is handled, I've implemented it in my code and just put in a call to "super" so I can set a breakpoint on it.

So long as you close the document window using the UI, you can execute the script above as many times as you like and the computer will dutifully re-open the document every time. However, if you execute a script like:

tell application "MyApp"
    open "<path to document>"
    -- do something here
    close document 1
 end tell.

Where you close the document through the script, then the document will never open again from a script. (it will open from the UI). In the instance that the open command fails, I get the following on the debugging terminal:

2005-06-28 09:22:13.939 MyApp[26020] Command: Standard Suite.open
Direct Parameter: <CFArray 0x103b5440 [0xa0727150]>{type = mutable-small, count = 1, values = (
0 : <CFURL 0x103b7010 [0xa0727150]>{type = 15, string = file:// localhost/Users/scott/Projects/MM Cross-Platform/Quality% 20Assurance/Test Files/A Simple Map with Sub-Topics.mmap, base = (null)}
)}
Receivers: (null)
Arguments: {
"" = (
file://localhost/Users/scott/Projects/MM Cross- Platform/Quality Assurance/Test Files/A Simple Map with% 20Sub-Topics.mmap
);
}
2005-06-28 09:22:13.939 MyApp[26020] Result: (null)


It looks like the command is sent and received properly, but the reply is an immediate "null".

In this case the document controller never receives the openDocumentWithContentsOfURL:display:error: call (nor does it receive documentForURL:)

So far as I can tell, this problem lies strictly with the internal event handling within the Cocoa framework. My application doesn't appear to be affecting the processing of this event in any way. However, I wanted to ask if other folks may have run into similar problems to find out if my application may be affecting the event handling in some way I haven't anticipated. Any thoughts?

Scott



_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden


  • Follow-Ups:
    • Re: NSApplication's Apple Event Handling
      • From: Bill Cheeseman <email@hidden>
  • Prev by Date: Re: Calling CFM Code
  • Next by Date: Re: NSCell Subclass Editing Weirdness
  • Previous by thread: Re: Thwarting classdump, etc.
  • Next by thread: Re: NSApplication's Apple Event Handling
  • Index(es):
    • Date
    • Thread