# Issue with on focus

**URL:** <https://forum.inductiveautomation.com/t/issue-with-on-focus/76553>\
**Category:** Ignition\
**Tags:** ignition81, perspective\
**Created:** [July 18, 2023, 8:34pm UTC](https://forum.inductiveautomation.com/t/issue-with-on-focus/76553 "2023-07-18T20:34:18Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![mjohnson0238](https://avatars.discourse-cdn.com/v4/letter/m/4bbf92/32.png) [@mjohnson0238](https://forum.inductiveautomation.com/u/mjohnson0238)\
**Post date:** [July 18, 2023, 8:34pm UTC](https://forum.inductiveautomation.com/t/issue-with-on-focus/76553/1 "2023-07-18T20:34:19Z")

</div>

Good afternoon,

I am trying to input data in a textfield. At startup I want it to be active, cursor flashing in it. I have tried to do the following:

On the component itself, config event, onstartup, script self.focus()  
and I have tried on the perspective view, config event, onstartup, script self.getChild("root").getChild("TextField\_0").focus()

niether of which are sucessful. What am I doing wrong?

Then after I input that data I want it clear out and refocus on itself, I have this:

```auto
	Time = system.date.now()
	test_obj = self.session.custom.test_obj
	Name = self.session.custom.testName
	databaseConnection = "IgnitionHud"
	Badge_Num = self.props.text[1:11]
	for M in test_obj:
		pydict = M['value']
		if pydict['ShawEmployeeID'] == Badge_Num:
			isAccountedFor = pydict['isAccountedFor']
			Name = pydict['EmployeeFullName']
			if not isAccountedFor:
				system.db.runPrepUpdate("INSERT INTO SM_CheckIn (Time, Name, Badge_Num) VALUES (?,?,?)", [Time, Name, Badge_Num])
				self.props.text = ''
				self.focus()

```

As a change script on the text field.

This is being used on a tablet.

---

<div class="post-metadata">

**Author:** ![mjohnson0238](https://avatars.discourse-cdn.com/v4/letter/m/4bbf92/32.png) [@mjohnson0238](https://forum.inductiveautomation.com/u/mjohnson0238)\
**Post date:** [July 19, 2023, 1:08pm UTC](https://forum.inductiveautomation.com/t/issue-with-on-focus/76553/2 "2023-07-19T13:08:08Z")

</div>

UPDATE:

Not sure why this would matter but it does.

When opening the perspective project up via the app it doesnt focus on the textfield, but when opening via a web browser it does focus.

Any Ideas?
