opening app by double-clicking Finder documents

Deploying to Mac OS? Ask Mac OS specific questions here.

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

Post Reply
RobertC
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 46
Joined: Sun Feb 04, 2007 3:43 pm

opening app by double-clicking Finder documents

Post by RobertC » Mon Feb 05, 2007 10:55 am

Hello,

I may have overlooked something, but I can't find a way to do this:

(a) assign a document type to an application
(b) getting the application to start up and open a document when I double-click that document in the Finder.

Normally, when you double-click a document the Finder will activate the document's creator app and pass the document to the app.

Any way of doing that? I saw no arguments to the startup handler.

Thanks.

Obleo
Posts: 174
Joined: Mon Apr 10, 2006 10:35 pm
Location: Chicago
Contact:

Re: opening app by double-clicking Finder documents

Post by Obleo » Mon Feb 05, 2007 7:10 pm

Hello RobertC,

The set up for this is in the Standalone Builder Settings under OSX.

hope this helps

-obleo

RobertC
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 46
Joined: Sun Feb 04, 2007 3:43 pm

Post by RobertC » Mon Feb 05, 2007 7:24 pm

Hi Obleo,

Thanks. I inspected that already but could not see how to do it.


What do I fill in where in this box:


Image

Many thanks in advance.

RC

Obleo
Posts: 174
Joined: Mon Apr 10, 2006 10:35 pm
Location: Chicago
Contact:

Post by Obleo » Mon Feb 05, 2007 10:36 pm

Under the PLIST section

The Signature field identifies the application that should be launched when a file is open, most likely your own application code that was submitted and confirmed by apple. From a four character code

an example is 8BIM which is the application code for Adobe Photoshop.

The Document Type field is the four character code attached to each file. If the file is say PDF after the F their is a space for the fourth character. or for a PNG file it would be PNGf

Document Extension is the file type extension example mypicture.jpeg would be jpeg or jpg

both the document type and file type fields can have more than one listed fallow each entered by a comma.

If you have yet done so Setting the FileType property for saved or exported files from your app should be done. That way any file that was created by your application will launch your app when double clicking the file. There some other setting with the FileType property but if you search the documentation browser for FileType it list all the other properties and commands that link to it.

I hope that was not confusing.




Some other info on PLIST and creator codes info that may or may not help:

A good example of an existing PLIST file is looking at Apple's Preview app as it deals with many different file types.

Show Package Contents/ locate plist and view it either text edit or Property List Manager

It also shows how you could use your own file icons, but this would have to be done by editing the PLIST file from a editor from the development tools of OSX or a text editor.

Adding info; The creator code registration page;
http://developer.apple.com/datatype/creatorcode.php
(I takes up to 2 weeks to get a confirmation reply)

More info on PLISTS or Property Lists,

http://developer.apple.com/documentatio ... Files.html

Updated:
this might be a better info page on PLIST (property lists)
http://en.wikipedia.org/wiki/Property_list

-obleo

RobertC
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 46
Joined: Sun Feb 04, 2007 3:43 pm

Post by RobertC » Mon Feb 05, 2007 10:54 pm

Thanks Obleo, that was a great help.

I knew some of this (from way back in system 8.x), the position and names of the boxes threw me off.

The crucial info you supplied is that I have to set the filetype in Revolution before writing any documents, if I want those documents to refer back to the application.

Your answer was not confusing at all, thanks very much.

It immediately raises another problem though: I want my own 4 letter codes that I can use locally, without having to get one approved by Apple.
But I guess that the easiest way is to ask for a couple of codes, just to be sure of having no future conflict. Hmm... I wonder if they thought of a small range of codes reserved for development and playing around?

thanks,
Robert.

Obleo
Posts: 174
Joined: Mon Apr 10, 2006 10:35 pm
Location: Chicago
Contact:

Post by Obleo » Mon Feb 05, 2007 11:17 pm

You could just register one for future use (that way you have one to test and use down the road) Its free.

Also it is possible to change the App/ product name associated with a creator code if you own the code, It does take some time though, just keep one of the developer evangelists email address or what ever email address that you may have as It is not very easy getting a reply from any Apple personnel any other way when things like that come up.

or they do have a way to see if a code exists by typing one in , if it does not just do not register it and use it for development only (so you at least do not interfere with something that could be currently on your system). and if you need one in the future then submit one.

good luck.

-ob

RobertC
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 46
Joined: Sun Feb 04, 2007 3:43 pm

Post by RobertC » Tue Feb 06, 2007 8:21 am

I had found their page where you can try to see if a code is taken or not, but it does not work (some php bug I think). I have an ADC account and logged in, but it still did not work.

I'll just register a few.

Thanks again!

Out for now,
Robert.

Martin Koob
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 256
Joined: Sun May 27, 2007 8:19 pm

launching app by double clicking document - getting path

Post by Martin Koob » Sun Aug 26, 2007 3:42 am

I have registered a creator code with Apple for my application that I am developing using Revolution. From what I understand If I have a creator code set up in the standalone settings, double-clicking on a document in the finder with the same creator code will launch my standalone.

I have a handler that opens a document when it is opened from within the standalone. How would I get that handler to open the document that was double clicked in the finder. Is a parameter passed to the standalone containing the path to the document that was clicked?

I thought it may be the startup message might include that as a parameter but I don't see that in the documentation.

Any help would be appreciated

Martin

Janschenkel
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 977
Joined: Sat Apr 08, 2006 7:47 am
Location: Aalst, Belgium
Contact:

Post by Janschenkel » Sun Aug 26, 2007 4:49 pm

Hi Martin,

The Finder will send your application an appleEvent with the necessary information. You'll want to add a handler like this to your mainstack's script:

Code: Select all

on appleEvent pClass, pID
  if pClass is "aevt" then  -- the 'core' class of apple events
    if pID is "odoc" then
      -- the user opened a file from the finder
      -- find out which file, and open it
      request appleEvent data
      put it into tFilePath
      MyOpenFile tFilePath
    else if pID is "pdoc" then
      -- the user printed a file from the finder
      -- find out which file, and print it
      request appleEvent data
      put it into tFilePath
      MyPrintFile tFilePath
    else
      pass appleEvent
    end if
  else
    pass appleEvent
  end if
end appleEvent
Hope this helped,

Jan Schenkel.
Quartam Reports & PDF Library for LiveCode
www.quartam.com

Post Reply

Return to “Mac OS”