Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ofxDatGuiSliderEvent spitting twice #63

Closed
aferriss opened this issue Apr 5, 2016 · 1 comment
Closed

ofxDatGuiSliderEvent spitting twice #63

aferriss opened this issue Apr 5, 2016 · 1 comment
Labels

Comments

@aferriss
Copy link

aferriss commented Apr 5, 2016

The slider events seem to be getting called twice per click.

ofApp.h

ofxDatGui* gui;
ofxDatGuiSlider* guiMaxW;
ofxDatGuiSlider* guiMaxH;
void onSliderEvent(ofxDatGuiSliderEvent e);

ofApp.cpp

void ofApp::setup(){
    gui = new ofxDatGui( ofxDatGuiAnchor::TOP_LEFT );
    guiMaxW = gui->addSlider("Max Width", 1,200,64);
    guiMaxH = gui->addSlider("Max Height", 1, 200,32);
    gui->onSliderEvent(this, &ofApp::onSliderEvent);
}

void ofApp::onSliderEvent(ofxDatGuiSliderEvent e){
    if(e.target->is("Max Width")){
        cout<<ofToString(e.value)<<endl;
    }else if (e.target->is("Max Height")){
        cout<<ofToString(e.value)<<endl;
    }
}

If I click my slider it will print the value that the slider has when I first clicked, and then the value that I moved the slider to. Am I right in thinking it should only print the latter? Did I set something up incorrectly?

Edit: I should clarify that this only happens when clicking on the bar of the slider itself. Setting the numerical value in the box only triggers the event once, as does sliding the mouse side to side after an initial click. That initial click still triggers two events though.

I'm wondering if mousePressed and mouseDragged are both sending events?

@braitsch
Copy link
Owner

braitsch commented Apr 6, 2016

Hi, this is a bug. The event should only dispatch when the value of the slider has changed, e.g. onMouseDragged or onInputChanged. I'll push up a fix in a few minutes. Thanks for reporting this!

@braitsch braitsch added the bug label Apr 6, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants