Skip to content

Commit

Permalink
Merge pull request #210 from robotools/list2EditCellIndex
Browse files Browse the repository at this point in the history
  • Loading branch information
typesupply authored May 8, 2024
2 parents b9a88e1 + 3dad8f2 commit 32ce13d
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions Lib/vanilla/vanillaList2.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ def initWithTableView_(self, tableView):
self._cellToValueConverters = {} # { identifier : function }
self._groupRowCellClass = None
self._groupRowCellClassKwargs = {}
self._editedRowIndex = None
self._cellWrappers = {} # { nsView : vanilla wrapper } for view + wrapper reuse purposes
self._valueGetters = {} # { identifier : options (see below) }
self._valueSetters = {} # { identifier : options (see below) }
Expand Down Expand Up @@ -246,8 +247,14 @@ def cellEditCallback(self, sender):
value = sender.get()
self.setItemValueForColumnAndRow(value, identifier, row)
wrapper = self.vanillaWrapper()
self._editedRowIndex = row
if wrapper._editCallback is not None:
wrapper._editCallback(wrapper)
self._editedRowIndex = None

@python_method
def getEditedRowIndex(self):
return self._editedRowIndex

# Drag

Expand Down Expand Up @@ -876,6 +883,18 @@ def setSelectedIndexes(self, indexes):
rowIndexes = makeIndexSet(rowIndexes)
self._tableView.selectRowIndexes_byExtendingSelection_(rowIndexes, False)

def getEditedIndex(self):
"""
Return the index of the edited row.
"""
return self._dataSourceAndDelegate.getEditedRowIndex()

def getEditedItem(self):
"""
Return the item of the edited row.
"""
return self.get()[self.getEditedIndex()]

def scrollToSelection(self):
"""
Scroll the selected rows to visible.
Expand Down

0 comments on commit 32ce13d

Please sign in to comment.