Textfield Auto focus

Hi,

I'm trying to auto-focus a text field after a tag (bool) change...

To monitor the change, I have a parameter on-screen where the change happens. The textfield is used for barcode scanning and once the barcode is scanned, we wait for a tag to change to True.

I've written an onChange script for when the tag is true to save some data in a table and then to refresh the textfield back to empty. But we're having a hard time trying to focus the textfield after its reset to empty...

Currently we're using - {path to textfield component}.focus() at the end of the change script. The rest of the change script is working as expected, except the focus part. Not sure where we're going wrong with this one... Any help would be highly appreciated...

Thanks!

Since you are using perspective, I would use the barcodescannerinput component. You can set it up to look for a certain regex pattern, or starting and stopping characters for framing. This way, you don't have to worry about focusing a text field.

.focus() only works when the component is inside a container that already has focus, so you might try focusing its parent container(s) first. You can steal focus from a parent or sibling, but not a cousin.