Project not saving, bug or doing something wrong?


#1

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


#2

Hi @alemuri,

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


#3

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


#4

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


#5

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

https://dl.dropboxusercontent.com/u/7614716/JUCEVideo.avi

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


#6

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

void mygui::buttonClicked (Button* buttonThatwasClicked)
{
    //[UserbuttonClicked_Pre]
    //[/UserbuttonClicked_Pre]

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

    //[UserbuttonClicked_Post]
    //[/UserbuttonClicked_Post]
}

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.

#7

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