diff --git a/addons/ofxGui/src/ofxInputField.cpp b/addons/ofxGui/src/ofxInputField.cpp index b1627ed7027..59442e66378 100644 --- a/addons/ofxGui/src/ofxInputField.cpp +++ b/addons/ofxGui/src/ofxInputField.cpp @@ -419,11 +419,15 @@ bool ofxInputField::mouseReleased(ofMouseEventArgs &){ //----------------------------------------------------------- template bool ofxInputField::mouseScrolled(ofMouseEventArgs & mouse){ + if(!isGuiDrawing() || insideSlider){ + //when insideSlider it is the slider object who is in charge of handling the scrolling + return false; + } if(b.inside(mouse)){ if(!bGuiActive){ - if(mouse.y>0 || mouse.y<0){ + if(mouse.scrollY>0 || mouse.scrollY<0){ double range = getRange(value.getMin(), value.getMax(), b.width); - Type newValue = value + ofMap(mouse.y,-1,1,-range, range); + Type newValue = value + ofMap(mouse.scrollY,-1,1,-range, range); newValue = ofClamp(newValue,value.getMin(),value.getMax()); value = newValue; } diff --git a/addons/ofxGui/src/ofxSlider.cpp b/addons/ofxGui/src/ofxSlider.cpp index c37936cc8be..8f4b69ce973 100644 --- a/addons/ofxGui/src/ofxSlider.cpp +++ b/addons/ofxGui/src/ofxSlider.cpp @@ -176,21 +176,25 @@ getRange(Type min, Type max, float width){ template bool ofxSlider::mouseScrolled(ofMouseEventArgs & args){ - if(state==Slider){ - if(mouseInside){ - if(args.scrollY>0 || args.scrollY<0){ - double range = getRange(value.getMin(),value.getMax(),b.width); - Type newValue = value + ofMap(args.scrollY,-1,1,-range, range); - newValue = ofClamp(newValue,value.getMin(),value.getMax()); - value = newValue; + if(isGuiDrawing()){ + if(state==Slider){ + if(mouseInside){ + if(args.scrollY>0 || args.scrollY<0){ + double range = getRange(value.getMin(),value.getMax(),b.width); + Type newValue = value + ofMap(args.scrollY,-1,1,-range, range); + newValue = ofClamp(newValue,value.getMin(),value.getMax()); + value = newValue; + } + return true; + }else{ + return false; } - return true; }else{ - return false; + // the following will always return false as it is inside the slider. +// return input.mouseScrolled(args); } - }else{ - return isGuiDrawing() && input.mouseScrolled(args); } + return false; }