From d712d8aa2d70d0eb13d7a1813ef555890be2a878 Mon Sep 17 00:00:00 2001 From: Roy Macdonald Date: Thu, 4 Oct 2018 19:15:51 -0300 Subject: [PATCH 1/2] ofxGui - fixed scrolling over slider when not drawing --- addons/ofxGui/src/ofxInputField.cpp | 8 ++++++-- addons/ofxGui/src/ofxSlider.cpp | 26 ++++++++++++++++---------- 2 files changed, 22 insertions(+), 12 deletions(-) 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..d6c155630e5 100644 --- a/addons/ofxGui/src/ofxSlider.cpp +++ b/addons/ofxGui/src/ofxSlider.cpp @@ -176,20 +176,26 @@ 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; } } From ee51b6cb913cf8657c318298f1b0606cccd7a2cd Mon Sep 17 00:00:00 2001 From: Roy Macdonald Date: Tue, 16 Oct 2018 23:17:07 -0300 Subject: [PATCH 2/2] fixed return in non-void function --- addons/ofxGui/src/ofxSlider.cpp | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/addons/ofxGui/src/ofxSlider.cpp b/addons/ofxGui/src/ofxSlider.cpp index d6c155630e5..8f4b69ce973 100644 --- a/addons/ofxGui/src/ofxSlider.cpp +++ b/addons/ofxGui/src/ofxSlider.cpp @@ -192,11 +192,9 @@ bool ofxSlider::mouseScrolled(ofMouseEventArgs & args){ }else{ // the following will always return false as it is inside the slider. // return input.mouseScrolled(args); - } - }else{ - return false; } + return false; }