Skip to content

Commit

Permalink
PathListingWidget : Delegate keypress to column
Browse files Browse the repository at this point in the history
  • Loading branch information
murraystevenson committed Aug 28, 2024
1 parent 2c59165 commit 08d5429
Showing 1 changed file with 17 additions and 9 deletions.
26 changes: 17 additions & 9 deletions python/GafferUI/PathListingWidget.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 08d5429

Please sign in to comment.