diff --git a/python/GafferUI/PathListingWidget.py b/python/GafferUI/PathListingWidget.py index 4779823a9b1..51bdc22789c 100644 --- a/python/GafferUI/PathListingWidget.py +++ b/python/GafferUI/PathListingWidget.py @@ -578,20 +578,21 @@ def __updateFinished( self ) : def __keyPress( self, widget, event ) : + # Use `__lastSelectedIndex` if available so that shift + keypress + # accumulates selection. + index = self.__lastSelectedIndex + assert( isinstance( index, ( type( None ), QtCore.QPersistentModelIndex ) ) ) + if index is not None and index.isValid() : + # Convert from persistent index + index = QtCore.QModelIndex( index ) + else : + index = self._qtWidget().currentIndex() + if ( event.key in ( "Up", "Down" ) or ( event.key in ( "Left", "Right" ) and self.__cellSelectionMode() ) ): - # Use `__lastSelectedIndex` if available so that shift + keypress - # accumulates selection. - index = self.__lastSelectedIndex - assert( isinstance( index, ( type( None ), QtCore.QPersistentModelIndex ) ) ) - if index is not None and index.isValid() : - # Convert from persistent index - index = QtCore.QModelIndex( index ) - else : - index = self._qtWidget().currentIndex() if not index.isValid() : return True @@ -637,6 +638,13 @@ def __keyPress( self, widget, event ) : self.__setSelectionInternal( selection, scrollToFirst=False ) return True + # Delegate the keyPress to the PathColumn, if it wants it. + + elif index.isValid() and self.getColumns()[index.column()].keyPressSignal()( + self.getColumns()[index.column()], self, event + ) : + return True + return False # Handles interactions for selection and expansion. Done at the level