3

I'm trying to make it so when a .ito file is clicked on my electron application opens and does something. I'm using electron-builder as my build system and see that it specifies a fileAssociations field in the configuration documentation. The issue I'm having is that it doesn't seem to be documented what function this calls in the application.

I've gone through all the documentation and tried implementing icpMain event listeners but couldn't find the name of the listener I was looking for.

1 Answer 1

4

I cannot exactly answer your question, since I don't need to set file associations in my Electron apps, but, on macOS, I've been able to have some code called when force-dropping a file from the Finder (with both Option and Command keys pressed) on my app icon in the Dock.

On macOS, you have to listen to the app event open-file from the main process.

From a renderer process, making use of remote, this code works for me:

require('electron').remote.app.on('open-file', (event, path) =>
{
    event.preventDefault();
    console.log(path);
});

On Windows, it seems that you have to parse process.argv to get the file path.

Not the answer you're looking for? Browse other questions tagged or ask your own question.