Skip to content

Instantly share code, notes, and snippets.

@acarabott
Created April 23, 2014 12:26
Show Gist options
  • Save acarabott/11213263 to your computer and use it in GitHub Desktop.
Save acarabott/11213263 to your computer and use it in GitHub Desktop.
get value from ofxUIIntSlider guiEvent
void ofApp::setup(){
myValue = 5;
gui->addIntSlider("MY_INT_SLIDER", 0, 10, myValue);
}
void ofApp::guiEvent(ofxUIEventArgs &e)
{
if (e.getName() == "MY_INT_SLIDER")
{
// the trick is in the cast....
ofxUIIntSlider *slider = (ofxUIIntSlider *) e.widget;
myValue slider->getValue();
}
}
void ofApp::exit()
{
gui->saveSettings("settings.xml");
delete gui;
}
// irrelevant methods ommited
#pragma once
#include "ofMain.h"
#include "ofxUI.h"
class ofApp : public ofBaseApp{
public:
void setup();
void guiEvent(ofxUIEventArgs &e);
void exit();
private:
int myValue;
ofxUICanvas *gui;
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment