From 5ec877512f0d9c1084e5f74574d454f1f79a033a Mon Sep 17 00:00:00 2001 From: Eric Mehl Date: Fri, 13 Sep 2024 11:42:38 -0400 Subject: [PATCH] NumericWidget : Mouse wheel adjust value Fixes #6009. --- Changes.md | 1 + python/GafferUI/NumericWidget.py | 14 ++++++++++++++ 2 files changed, 15 insertions(+) diff --git a/Changes.md b/Changes.md index bd6af8aa179..b4b0b323fb9 100644 --- a/Changes.md +++ b/Changes.md @@ -33,6 +33,7 @@ Improvements - Improved layout of Box node plug creator visibility toggles. - ArnoldShader : Moved the `toon` shader's `*_tonemap_hue_saturation` parameters to appropriate sections in the UI. - File Browser : The "Type" column can now be sorted. This sorts directories separately from files, which are sorted by their extension. +- NumericWidget : Added the ability to use the mouse wheel to adjust values in the same manner as Up and Down (#6009). Fixes ----- diff --git a/python/GafferUI/NumericWidget.py b/python/GafferUI/NumericWidget.py index 2ed1f2811f9..67b8c61f029 100644 --- a/python/GafferUI/NumericWidget.py +++ b/python/GafferUI/NumericWidget.py @@ -60,6 +60,7 @@ def __init__( self, value, **kw ) : self.__dragStart = None self.keyPressSignal().connect( Gaffer.WeakMethod( self.__keyPress ), scoped = False ) + self.wheelSignal().connect( Gaffer.WeakMethod( self.__wheel ), scoped = False ) self.buttonPressSignal().connect( Gaffer.WeakMethod( self.__buttonPress ), scoped = False ) self.dragBeginSignal().connect( Gaffer.WeakMethod( self.__dragBegin ), scoped = False ) self.dragEnterSignal().connect( Gaffer.WeakMethod( self.__dragEnter ), scoped = False ) @@ -141,6 +142,19 @@ def __keyPress( self, widget, event ) : return False + def __wheel( self, widget, event ) : + + assert( widget is self ) + + if not self.getEditable() : + return False + + scaleFactor = 15.0 + + self.__incrementIndex( self.getCursorPosition(), event.wheelRotation / scaleFactor ) + + return True + def __incrementIndex( self, index, increment ) : text = self.getText()