Focus table after system messagebox

Hi, i need to get this to work. so i need to get a table back to focus and to the selected row after system.gui.messagebox. the operator would clear the message but i need that after the clear the table row and column are focused. so they would input again without the need to select the table again.

                    "selectlo=system.db.runScalarPrepQuery(QselectItemlot, [newValue, lotid])
		if selectlo != None:

			system.gui.messageBox("That Pallet was already Scanned, please choose another")

			self.data = system.dataset.deleteRow(self.data, rowIndex)
			self.selectedRow = len(system.dataset.toPyDataSet(self.data)) - 1
			def addRow():
				self.parent.getComponent('Add Row').doClick()
				self.selectedRow = len(system.dataset.toPyDataSet(self.data)) - 1
				self.selectedColumn = 0
			system.util.invokeLater(addRow)    "

I think you’re looking for .requestFocus(True) - use this on the table component like table.requestFocus(True), I think that should do what you want.

thanks it’s almost correct. so after that the tables goes to focus. but not the row. even though the row it is selected. i still need to press Tab once in order to go to that row.
any ideas?

got it to work by adding

from java.awt import Robot
from java.awt.event import KeyEvent

robot = Robot()
robot.keyPress(KeyEvent.VK_TAB)

1 Like