Skip to content

Commit

Permalink
NumericWidget : Mouse wheel adjust value
Browse files Browse the repository at this point in the history
  • Loading branch information
ericmehl committed Sep 17, 2024
1 parent 5242530 commit 8a7bf4d
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
1 change: 1 addition & 0 deletions Changes.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,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 <kbd>Up</kbd> and <kbd>Down</kbd> (#6009).

Fixes
-----
Expand Down
14 changes: 14 additions & 0 deletions python/GafferUI/NumericWidget.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 )
Expand Down Expand Up @@ -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()
Expand Down

0 comments on commit 8a7bf4d

Please sign in to comment.