I would like to open files with the extension .test123
with my app. It works, but only if the app was already running before double-clicking the file. Not if opening the file launches the app.
I have set the Document File Extensions
in my Projucer project to .test123
. When I open my app first, and then double-click on the Foo.test123
file, anotherInstanceStarted
gets called with the commandLine
set to the file path – good Also, I can drag
Foo.test123
onto my app, and it works fine as well.
Problem: With the app not already running, double-clicking Foo.test123
does open my app, but just calls initialise
with empty commandLine
. The same if I drag Foo.test123
onto my app.
Has someone else encountered this, and how do you handle this case? Projucer does it correctly, but I couldn’t find the part in the Projucer code that fixes this…
My code to reproduce it:
#include "../JuceLibraryCode/JuceHeader.h"
class OpenWithTestApplication : public JUCEApplication
{
public:
OpenWithTestApplication() {}
const String getApplicationName() override { return ProjectInfo::projectName; }
const String getApplicationVersion() override { return ProjectInfo::versionString; }
bool moreThanOneInstanceAllowed() override { return false; }
void initialise (const String& commandLine) override
{
AlertWindow::showMessageBox(AlertWindow::NoIcon, "initialise", commandLine);
}
void anotherInstanceStarted (const String& commandLine) override
{
AlertWindow::showMessageBox(AlertWindow::NoIcon, "anotherInstanceStarted", commandLine);
}
void shutdown() override {}
void systemRequestedQuit() override { quit(); }
};
START_JUCE_APPLICATION (OpenWithTestApplication)