Frage

I developped an application for mac using mono and gtk#.
The problem is the default filehandler. I register my application using this Info.plist (snippet)

...
<array>
    <dict>
        <key>CFBundleTypeName</key>
        <string>My Filetype</string>
        <key>CFBundleTypeIconFile</key>
        <string>file.icns</string>
        <key>CFBundleTypeRole</key>
        <string>Editor</string>
        <key>CFBundleTypeExtensions</key>
        <array>
            <string>ext</string>
            <string>EXT</string>
        </array>
        <key>LSIsAppleDefaultForType</key>
        <true/>
    </dict>
</array>
....

It registers correctly (the icon is matching, opens my application), but whenever I open the file following message appears:

The document "test.ext" could not be opened. mono cannot open files of this type.

So how can I make it work?

War es hilfreich?

Lösung

I found it out by myself:

  1. Include https://github.com/mono/monodevelop/tree/master/main/src/addins/MacPlatform/MacInterop to your project.

  2. use this code

    ApplicationEvents.OpenDocuments+= delegate (object sender, ApplicationDocumentEventArgs e) {
        if (e.Documents != null && e.Documents.Count > 0) {
            // e.Documents holds the files
        }
        e.Handled = true;
    };
    
Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top