Writing XML Opened XML File To ValueTree


#1

So after finally getting a hold of these ValueTrees, I would like to be able to open an xml file with a custom file extension and use this file to write the values to the application.

I understand that I can create a ValueTree from the exported XML file by using the fromXml() function, however if I double click on the file with the custom extension, how can I import the clicked XML file into JUCE to use said function?


#2

You need to change the operating system file extension association to open your application. (I am not sure if JUCE itself has anything for that…You might need to use operating APIs directly or do the association in an installer for your application. ) Then in your application you will need to handle the passed in command line argument which should contain the file name of the double clicked file. (In void JUCEApplication::initialise (const String& commandLine))


#3

I’ve set the document file extension under the exporters panel in the Projucer, and this adds the file to the OS’ ‘Open With’ popup menu (mac in this case, but I’d assume Windows is a similar process). To be more specific, how do I go about handling the passed in command line argument? Where does it get passed to?

edit: after a proper re-read of your response I realise you pointed me to the initialise function!


#4

I am not seeing that document extension option in Projucer for Windows :unamused: