Hello,
I'm using Ignition version 8.1.26 and I'd like to have Excel-like cell behavior in my table for Tab and Enter keypresses. I thought I could script this with an onKeyPress event but I'm not having any luck.
Here is what I have. I'm really new to python so I'm sure my code is really bad.
def runAction(self, event):
# Get the currently selected cell coordinates
#I don't think this part is working.
selectedRow = self.getSibling('Table1').props.selection.selectedRow
print(selectedRow)
selectedColumn = self.getSibling('Table1').props.selection.selectedColumn
print(selectedColumn)
if event.keyChar == '\t': # Tab key
# Calculate the next column index
nextColumn = selectedColumn + 1
# Check if we've reached the end of the row
if nextColumn >= event.source.data.columnCount:
# Move to the first cell of the next row
nextRow = selectedRow + 1
if nextRow >= event.source.data.rowCount:
nextRow = 0 # Cycle back to the first row
event.source.selectedRow = nextRow
event.source.selectedColumn = 0
else:
event.source.selectedRow = selectedRow
event.source.selectedColumn = nextColumn
elif event.keyChar == '\n': # Enter key
# Calculate the next row index
nextRow = selectedRow + 1
# Check if we've reached the end of the table
if nextRow >= event.source.data.rowCount:
nextRow = 0 # Cycle back to the first row
event.source.selectedRow = nextRow
event.source.selectedColumn = selectedColumn
Thank you,