what do you mean by “doesn’t work” in all this? you’ve never really shown what’s the problematic code, i suppose you are doing some kind of test later on that variable and the problem is probably there. perhaps you can create a small example that shows the problem and post the full code
hello @arturo,
here is a very short version of the program. Basically I am trying to pass via xml some settings to control the KeyRelease() events.
On my stage I have some buttons that are triggered by booleans flags. When I say that it doesn’t work, I mean that the event on stage is not triggered. In this short example below the button is substituted by a rectangle, but it gives the idea.
I say that it doesn’t work as, if I use another ASCII with the same code, that works nicely (change 32 with any other e.g., 121 (y)).
I was reading here that the space character is special as it can be considered as a graphical character, control or both.
The behaviour that I am having at the moment is that the program works with the supposed-to-be-correct code only if I press ctrl+space. I don’t know much about all of this, so I am literally throwing guesses.
Another note:I just realised that the XML code behaves the same way for either these options
<settings>
<playButton> </playButton>
<playButton> </playButton>
<playButton><![CDATA[ ]]></playButton>
</settings>
that means that the program works, again, only if I press ctrl+space
//code below
bool var;
void ofApp::setup(){
//XML settings
//load the xml
settings.load("settings.xml");
if(settings.exists("//playButton") && !settings.getValue<string>("//playButton").empty()) {
playKey = settings.getValue<string>("//playButton");
} else {
playKey = ' ';
}
}
//--------------------------------------------------------------
void ofApp::draw() {
if (var){
ofDrawRectangle(10,10,100,100);
} else {
ofDrawRectangle(10, 10, 200, 200);
}
}
//--------------------------------------------------------------
void ofApp::keyReleased(int key) {
if (key == ofToChar(playKey)) {
var = !var;
}
}
I hope this helps clarifying something., and thanks again for this!