Projucer seems to delete some inherited methods

I inherited my class OverdriveProcessorEditor from the AudioProcessorEditor Class as well as the Slider and the Timer Class. The GUI has been designed with the Projucer. I’m aware that if you do it that way any code that has been added in the IDE won’t be retained unless it’s in the dedicated area. BUT I overrode the sliderValueHasChanged without placing it in the “custom-code-area”. It’s still there whenever I reopen the project in Pojucer. Now for my class to compile, it is mandatory to override the timerCallback() method, which I do right below sliderValueHasChanged in the cpp-file as well as in the h-file.
Now the strange thing is that the sliderValueHasChanged method is retained, while the timerCallback() is not, which is pretty annoying since I always have to correctly reimplement that method. Should I override timerCallback() in that dedicated area for custom code and if yes, why? Why won’t the sliderValueHasChanged() method will be deleted as well? Thank you for any help.
Cheese, Luke

Show us the code …

When you make your Component class inherit other classes, you must do that in the projucer. See the page Class entry parent classes. It should read: “public Component, public Slider::Listener, public Timer” That way it will create the callback function and create an area inside that method where you can place your code. You can also select which callbacks you want the projucer to generate…
If you are done with the gui editor and want to continue on your own, you can remove the comment block at the end of the cpp file, where the definition is placed for the gui editor (look for BEGIN_JUCER_METADATA). That way projucer will not touch your code again. But it will also no longer show the component editor page.

It does what it says, every code outside these “place your own code here” blocks will be overwritten. Otherwise it can’t apply the changes you do on the component editor…

Hey there!
Thanks for your reply. I thought I had forgot to write the classes I wanted to inherit from in the Projucer under “Parent Classes”. Which I did not. Projucer->PluginEditor.cpp->Parent Classes: “public AudioProcessorEditor, public SliderListener, public Timer” - this is what I wrote in Projucer. If I open the project in XCode, everything seems to be inherited as it should.

class Overdrive3001AudioProcessorEditor : public AudioProcessorEditor,
public SliderListener,
public Timer
Overdrive3001AudioProcessorEditor (Overdrive3001AudioProcessor(& owner));

//[UserMethods]     -- You can add your own custom methods in this section.
Overdrive3001AudioProcessor* getProcessor() const {return static_cast<Overdrive3001AudioProcessor*>(getAudioProcessor());};

void paint (Graphics& g) override;
void resized() override;
void sliderValueChanged (Slider* sliderThatWasMoved) override;
void timerCallback() override; // <- this wont stay

The interesting thing is, that when I write the code right in the Projucer it’s gone once I leave the file (PluginEditor.h)

I just don’t understand why sliderValueChanged() stays…

This is being done by the GUI editor of the Projucer. If your component contains a slider (and the “generate slider callback” checkbox is ticked - which is the default) the Projucer will always create the slideValueChange callback. Any other methods which are not in the UserMethods section will be deleted automatically. Try moving the timerCallback into that section.

1 Like

That was the answer I was looking for. Thank you all and especially you Fabian.
Cheese, Luke