Text Input Clear Text

I am attempting to scan multiple 10 character long barcodes into a table using the same text field input. A key released event populates the Table. I cannot for the life of me get the text box to clear after a scan of 10 characters or more. I have tried lots of things, such as invoke later and other component bindings etc.

The table updates and the test message ‘clear attempted’ is printed to the console so I know the function is running. It will not clear the text field. Please help, I have tried lots of other methods to no avail.

id= event.source.text
if len(spoolID) >= 10:
	def reset():
		event.source.text = ""
		#print "clear attempted"			
	#tableData = event.source.parent.getComponent('Table').data
	#tableData = system.dataset.addRow(tableData,[id])
	#event.source.parent.getComponent('Table').data = tableData
	reset()

Ign 8.1.3

The only strange thing I see with your script is you have id=event.source.text but your if statement is if len(spoolID). Does the text box have a binding to the text property? Where is the this script located? In the text box’s propertyChange event?

Try turning off ‘Reject Updates During Edit’

my propertyChange script:

if event.propertyName == 'text':
	value = event.newValue
	if len(value) >= 10:
		table = event.source.parent.getComponent('Table')
		table.data = system.dataset.addRow(table.data, [value])
		event.source.text = ''

Sorry, my bad. That was a typo.

Should have been:
spoolID = event.source.text

Thanks, worked a treat. I would never have thought of that. :slight_smile: