[Openmcl-devel] mac filetype association

Paul Krueger plkrueger at comcast.net
Wed Feb 3 11:31:45 PST 2016

On Feb 3, 2016, at 11:34 AM, Arthur Cater <arthur.cater at ucd.ie> wrote:
> Hi, I’d like to get an application (built with ccl) to open when a file of a particular filetype
> is double-clicked, and I can do that. However I’d like it to do something other than
> open a Hemlock window for the file. I’ve tried to (advise ed … :when :around) but that does not
> do the trick, presumably somewhere other than ED needs such advice. Please … advise!
> Arthur
> _______________________________________________
> Openmcl-devel mailing list
> Openmcl-devel at clozure.com
> https://lists.clozure.com/mailman/listinfo/openmcl-devel

There are a variety of different things that you might be trying to do (each with its own difficulties). If you want to try Ron’s suggestion, I have attached a pdf that contains my own notes on how toplevel functions work. If you are doing a fairly simple single-purpose app, that could work. If you are you doing a custom gui app on a mac it can get a lot more complicated.

The rest of this assumes you are on a mac, so disregard if that isn’t the case.

When you said that you could get your app to open your file type, I can imagine a couple of ways you might have done that. You might have just done a “Get Info" on a file of that type and then told it to open up your app by default for that file type. That’s fairly easy. The more standard way for a new application to do that is to modify the info.plist file in its application bundle. When that bundle is saved or loaded as an application the OS will record the association declared in the info.plist file and thereafter open any files of that type by that app. That’s a better way to go because you can then copy your app to another computer which will then know to open your app when those files are double-clicked.

The other reason to change the info.plist is that you can associate an NSDocument Class with your file and an instance of that class will be created when your file is opened. Then that class and its associated methods will determine what happens (i.e. how your file is loaded and displayed, etc.) That can add its own sorts of complexity.

If you are more ambitious, I created an extensive contrib that contains tools that let you build cocoa applications with your own file types, display windows, and actions. It creates application bundles and populates them as you specify with an interactive window. It has support for saving and restoring any document files that you define in the same way that other Mac apps do. The contrib also contains extensive support for data type conversions that you might want to do for Cocoa apps. It does take some effort to understand everything, but if you want to build your own app with its own bundle, etc. I believe that this is a relatively easy way to go. Look for "CCL Cocoa Developer Tools Tutorial.pdf” in the CCL distribution and it will walk you through the entire process. 

-------------- next part --------------
A non-text attachment was scrubbed...
Name: toplevel-function.pdf
Type: application/pdf
Size: 39403 bytes
Desc: not available
URL: <https://lists.clozure.com/pipermail/openmcl-devel/attachments/20160203/645a878d/attachment.pdf>
-------------- next part --------------

More information about the Openmcl-devel mailing list