@bunnyHat wrote:
Hi there, I am using the text field widget from the ofxUI addon. What I would like to do is to grab the string cityOutput variable form the guiEvent() method and reuse it in draw(). I can't seem to figure out how to do it because void guiEvent() does not return anything, and if i change it to string guiEvent() and return the string, ofAddListener() won't take it as an argument.
void ofApp::guiEvent(ofxUIEventArgs &e) { string name = e.getName(); if(name == "city"){ ofxUITextInput *ti = (ofxUITextInput *) e.widget; string cityOutput = ti->getTextString(); cout << cityOutput << endl; if(ti->getInputTriggerType() == OFX_UI_TEXTINPUT_ON_ENTER) { cout << "ON ENTER: "; } else if(ti->getInputTriggerType() == OFX_UI_TEXTINPUT_ON_FOCUS) { cout << "ON FOCUS: "; } else if(ti->getInputTriggerType() == OFX_UI_TEXTINPUT_ON_UNFOCUS) { cout << "ON BLUR: "; } } }
Posts: 2
Participants: 2