Projucer - create my own user code zones


as we know Projucer allows to write custom code (headers, pre and post constructors…), in order to avoid this code to be erased when changes are made and file re-generated.
I would like to add custom code in other zones of the code, where tags were not originally put.

Is it possible?



Yes, you can create your own template file - there’s an option for this in the GUI editor’s class settings page, IIRC.

template file??
I am not sure I got you…

I only need to know if there is some kind of general

//[Headers] You can add your own extra header files here...

that would allow me to add custom code at other places in the files, with no risk to be overriden

Yes, you can do that by creating your own version of the template file that the projucer uses for your component.

Have a look at the existing templates as an example, e.g.

1 Like

ooook, got it

does it mean I need to compile projucer with this modified template?

No - I think each GUI component can have its own template file specified in its settings.

Ok indeed I see that in the class tab of the gui editor for given component, in General Class Settings, we have a field “Template File”, what is it expecting from me? Path for a cpp template file? or other format?

The reason I sent you that link and told you to look at that file is because that’s the format it uses.

ok so just to close this thread, I have investigated the projucer code, and got to the conclusion that we simply need to create 2 files myTemplate.cpp and myTemplate.h (same names required), and put them in the same directory as the concerned component file.

Then in the component settings (in the GUI editor) you simply input the myTemplate (with no extension)

save the whole, and the new field magically appears now in our auto-generated file


thanks for help man!


1 Like

Is there a way to change the template used by all components ?

I modified JUCE\extras\Projucer\Source\BinaryData\jucer_ComponentTemplate.cpp and jucer_ComponentTemplate…h but the ProJucer seems to ignore my changes …

Or if it’s not possible could you please add the old jucer back in the Juce repo ? Because that’s something it could do …

Maybe for this, you need to recompile the Jucer, so your changes will be taken into account?