Page 1 of 1

Double click file to open it in app on MAC

Posted: Tue Jun 11, 2013 2:11 pm
by CenturyMan1979
Hey All,

So I added my custom ext in the Info.plist settings for my app and now when I double click a file with that extension it opens up my app that is associated with that extension. My problem is I can't seem to figure out how to get the filename of the file that was double clicked. On pc you can just get it with $1 but what do I need to do to access it on MAC?

Re: Double click file to open it in app on MAC

Posted: Tue Jun 11, 2013 4:09 pm
by FourthWorld

Re: Double click file to open it in app on MAC

Posted: Tue Jun 11, 2013 4:19 pm
by CenturyMan1979
Thanks for the input fourthworld but my issue was not setting the file association on mac which you can do in the standalone application settings for mac. I was having issues getting the file name of a file I double clicked on to open it. i solved my issue with some code someone provided in the contributor notes of the livecode dictionary.

Code: Select all

on appleEvent theClass,theID
   if theClass is "aevt" and theID is "odoc" then
      request appleEvent data
      put it into theFiles ## files OS is requesting your application opens, one per line
      if theFiles is not "not found" and theFiles is not empty then
         ## code to open theFiles
      end if
   else
      pass appleEvent
   end if
end appleEvent

Re: Double click file to open it in app on MAC

Posted: Tue Jun 11, 2013 5:23 pm
by FourthWorld
Glad you found the solution. I've dropped a note to the author of the article I linked to, suggesting he include an example appleEvent handler to make that discussion more complete.