Project not saving, bug or doing something wrong?

Hi all, first of all i want to say that i’m just starting, i have few C++ background and i’m not an expert, and i hope to improve with JUCE, my problem is this, i’m starting a new Gui component colled “mygui”, i add a texteditor and a button for the most basic exercise, then i go in the code section of mygui.cpp and i add this under:

void mygui::buttonClicked (Button* buttonThatWasClicked)
if (buttonThatWasClicked == textButton)
textEditor->setText(“first try”);

i save everything, with Save Project and Save all, build and launch the program and it work perfectly, but if i click for example on mygui.h and then i comeback in mygui.cpp and go to the code again, everything is reset to default and i lose my code, but the curious thing is that if i manually open mygui.cpp out of JUCE my code is there, is like if JUCE reset it not opening the real one, am i doing something wrong or is this some kind of bug?
tested on Windows 7 and Windows 10, same problem.
Thx in advanced ant Congratulation because JUCE is fantastic

Hi @alemuri,

That sounds like a bug, but I’m afraid I can’t reproduce it. Is there anything unusual about your computer?

Just sounds to me like you’re looking at two different files…?

don’t think my computer have something unusual and definitely is the same file, but is so strange also to me, if it was a problem inside JUCE someone would have noticed something like this before me, i will do a video and up the link

Ok here is the video, hope dropbox is fine, how you can notice another strange thing is that the first time that i write on the button clicked the cursor go to the end of the page, and like i said happens on win 10 and win 7, thx in advance for the help

Just to give an update, i tried to reproduce this with a normal .cpp file and it work fine, the problem is only with a GUI component

Ahhh… you need to put your code between the //[UserButtonCode_textButton] and //[/UserButtonCode_textButton] like this:

void mygui::buttonClicked (Button* buttonThatwasClicked)

    if (buttonThatWasClicked == textButton)
        //[UserButtonCode_textButton] -- add your button handle code here...
        textEditor->setText ("first attempt");


The Projucer will re-generate that file every time you go into the GUI editor. When regenerating it will only keep things that are between the [blabla][/blabla] tags.

See also the comment at the top of the file:

Be careful when adding custom code to these files, as only the code within
the "//[xyz]" and "//[/xyz]" sections will be retained when the file is loaded
and re-saved.

ohh!! that was the problem, i was writing the code in the end of it thinking that it was just comment, totally my bad, thx a lot, i hope to improve soon with JUCE, i like it so much