Double click file to open it in app on MAC

Anything beyond the basics in using the LiveCode language. Share your handlers, functions and magic here.

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

Post Reply
CenturyMan1979
Posts: 86
Joined: Tue May 15, 2012 5:56 pm

Double click file to open it in app on MAC

Post by CenturyMan1979 » Tue Jun 11, 2013 2:11 pm

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?

FourthWorld
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 10058
Joined: Sat Apr 08, 2006 7:05 am
Contact:

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

Post by FourthWorld » Tue Jun 11, 2013 4:09 pm

Richard Gaskin
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn

CenturyMan1979
Posts: 86
Joined: Tue May 15, 2012 5:56 pm

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

Post by CenturyMan1979 » Tue Jun 11, 2013 4:19 pm

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

FourthWorld
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 10058
Joined: Sat Apr 08, 2006 7:05 am
Contact:

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

Post by FourthWorld » Tue Jun 11, 2013 5:23 pm

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.
Richard Gaskin
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn

Post Reply