How to set focus

This is the first item returned by searching "Ignition text field set focus" on Google so I think it's appropriate to add here. When the methods above didn't work for me I realized I was using a Text Area, not a Text Field. The script provided at Set focus on any input control was useful for finding out that for a Text Area the request focus script is really

getComponent('Text Area').components[0].components[0].requestFocus()

This sets the cursor at position 0. I wanted to set it at the end of the text, so I ended up using

c = getComponent('Text Area').components[0].components[0]
c.requestFocus()
c.setCaretPosition(len(c.text))
1 Like