# How to set focus in Form component

**URL:** <https://forum.inductiveautomation.com/t/how-to-set-focus-in-form-component/113154>\
**Category:** Ignition\
**Tags:** perspective, ignition83\
**Created:** [January 8, 2026, 4:27pm UTC](https://forum.inductiveautomation.com/t/how-to-set-focus-in-form-component/113154 "2026-01-08T16:27:31Z")\
**Posts on this page:** 11\
**Page:** 1

<div class="post-metadata">

**Author:** ![petr.sasin](https://avatars.discourse-cdn.com/v4/letter/p/9f8e36/32.png) [@petr.sasin](https://forum.inductiveautomation.com/u/petr.sasin)\
**Post date:** [January 8, 2026, 4:27pm UTC](https://forum.inductiveautomation.com/t/how-to-set-focus-in-form-component/113154/1 "2026-01-08T16:27:31Z")

</div>

Hi everyone,

I am looking for a way to manage focus within a Form component. I have several text input fields and I need to populate them using a barcode scanner configured as a keyboard wedge. Proper focus management is crucial for this application. I am using a Honeywell CT37 Android device with a built-in scanner.

I am struggling with two specific issues:

1. **Initial Focus:** When the screen opens, no field in the Form has focus by default. I have to manually click on a field to start scanning. Is there a way to auto-focus a specific field on view startup? I have already tried `self.focus()` in **Form** `startup` event but it doesn’t work.
2. **Focus Progression after Scan:** When using a regular keyboard, pressing Enter or Tab moves the focus to the next field as expected. However, when using the scanner, the value is entered, but the focus remains on the current field. The scanner is configured to send a `\r` (Carriage Return) character after each scan, but the Form doesn't seem to trigger the focus change.

My Form setup is shown below:

 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/b/b/bbf0c841676f738a601496260cd7ffaf7f9d2cb6.png)

---

<div class="post-metadata">

**Author:** ![Ryan\_Deardorff](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/ryan_deardorff/32/63815_2.png) [@Ryan\_Deardorff](https://forum.inductiveautomation.com/u/Ryan_Deardorff)\
**Post date:** [January 8, 2026, 4:39pm UTC](https://forum.inductiveautomation.com/t/how-to-set-focus-in-form-component/113154/2 "2026-01-08T16:39:04Z")

</div>

The ideal solution for initial focus would be a view “onLoad” handler that would fire when the view is done loading, which doesn’t exist yet (vote for it [here](https://ideas.inductiveautomation.com/ignition-features-and-ideas/p/perspective-view-onload-event-that-fires-when-the-view-is-done-loading)).

Instead, you’ll have to use the `onStartup` handler of the view, which may fire before the input you want focused is rendered, and use a `sleep()` delay:

```python
def runAction(self):
	import time
	
	time.sleep(0.5)	# wait half a second
	self.focus()

```

---

<div class="post-metadata">

**Author:** ![petr.sasin](https://avatars.discourse-cdn.com/v4/letter/p/9f8e36/32.png) [@petr.sasin](https://forum.inductiveautomation.com/u/petr.sasin)\
**Post date:** [January 8, 2026, 4:57pm UTC](https://forum.inductiveautomation.com/t/how-to-set-focus-in-form-component/113154/3 "2026-01-08T16:57:55Z")

</div>

Hi Ryan,

Thanks for the suggestion. However, the `onStartup` event doesn't seem to be the core issue here.

To test this, I added a "Test Button" to the screen to attempt to set focus manually once the View is fully loaded. In the `onActionPerformed` event of the button, I used the following script:

```python
def runAction(self, event):
    self.getSibling("Form").focus()

```

Even with this manual trigger, the focus is not being set to the Form (or the specific input field within it). It seems like calling `.focus()` on the Form component itself doesn't automatically delegate focus to its internal input fields.

Do I need to target the specific input component inside the Form directly, or is there a known limitation with focus delegation in the Form component?

---

<div class="post-metadata">

**Author:** ![Ryan\_Deardorff](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/ryan_deardorff/32/63815_2.png) [@Ryan\_Deardorff](https://forum.inductiveautomation.com/u/Ryan_Deardorff)\
**Post date:** [January 8, 2026, 4:59pm UTC](https://forum.inductiveautomation.com/t/how-to-set-focus-in-form-component/113154/4 "2026-01-08T16:59:41Z")

</div>

Focusing the Form component is not the same as focusing an input component within it. You’ll need to target that specific component (I would apply an `onStartup` handler on the specific component).

---

<div class="post-metadata">

**Author:** ![petr.sasin](https://avatars.discourse-cdn.com/v4/letter/p/9f8e36/32.png) [@petr.sasin](https://forum.inductiveautomation.com/u/petr.sasin)\
**Post date:** [January 8, 2026, 5:37pm UTC](https://forum.inductiveautomation.com/t/how-to-set-focus-in-form-component/113154/5 "2026-01-08T17:37:16Z")

</div>

Sure. Focusing the Form is not same as focusing a component within the Form, but I don’t know how to focus specific component within Form.  
If I try to call:

```python
# try to focus first text field within the Form
self.getSibling("Form").props.columns.items[0].rows.items[1].widgets[0].focus()

```

then it throw **AttributeError: 'com.inductiveautomation.perspective.gateway.script' object has no attribute 'focus'**

---

<div class="post-metadata">

**Author:** ![Ryan\_Deardorff](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/ryan_deardorff/32/63815_2.png) [@Ryan\_Deardorff](https://forum.inductiveautomation.com/u/Ryan_Deardorff)\
**Post date:** [January 8, 2026, 5:43pm UTC](https://forum.inductiveautomation.com/t/how-to-set-focus-in-form-component/113154/6 "2026-01-08T17:43:43Z")

</div>

Well again, I would just use an `onStartup` handler:

 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/5/2/52f67d2d0b1394861535e040c65b0c8efb7f7416.png)

But if you want to activate it some other way, you could have a button or whatever invoke `system.perspective.sendMessage()` and use a message handler instead. I don’t recommend ever using `getSibling/Child/Parent()` because such scripts will break if you ever start rearranging the layout.

---

<div class="post-metadata">

**Author:** ![petr.sasin](https://avatars.discourse-cdn.com/v4/letter/p/9f8e36/32.png) [@petr.sasin](https://forum.inductiveautomation.com/u/petr.sasin)\
**Post date:** [January 8, 2026, 5:51pm UTC](https://forum.inductiveautomation.com/t/how-to-set-focus-in-form-component/113154/7 "2026-01-08T17:51:03Z")

</div>

But You are talking about Text field and I’m talking about Form. Form component is new in Ignition 8.3

 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/d/7/d7ee0deab76d386bb64d6973963d5b78a03aeeda.png)

 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/1/e/1e9b0838d27afcf59b0b5cfc8259601b54d0721c.png)

---

<div class="post-metadata">

**Author:** ![Ryan\_Deardorff](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/ryan_deardorff/32/63815_2.png) [@Ryan\_Deardorff](https://forum.inductiveautomation.com/u/Ryan_Deardorff)\
**Post date:** [January 8, 2026, 5:57pm UTC](https://forum.inductiveautomation.com/t/how-to-set-focus-in-form-component/113154/8 "2026-01-08T17:57:42Z")

</div>

Oh, sorry, I haven’t used that yet and didn’t realize it doesn’t use nested components. But I image the `tabIndex` order of the “widgets” _should_ determine which input is focused initially. The default is 0, so if that’s what they’re all set to, you’d need to make sure only the one you want focused is set to that.

---

<div class="post-metadata">

**Author:** ![pturmel](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/pturmel/32/3295_2.png) [@pturmel](https://forum.inductiveautomation.com/u/pturmel)\
**Post date:** [January 8, 2026, 6:04pm UTC](https://forum.inductiveautomation.com/t/how-to-set-focus-in-form-component/113154/9 "2026-01-08T18:04:03Z")

</div>

BTW, if you chose the Form component in order to eventually support offline mode, be aware that offline mode won't run any UI event scripts.

---

<div class="post-metadata">

**Author:** ![petr.sasin](https://avatars.discourse-cdn.com/v4/letter/p/9f8e36/32.png) [@petr.sasin](https://forum.inductiveautomation.com/u/petr.sasin)\
**Post date:** [January 8, 2026, 6:08pm UTC](https://forum.inductiveautomation.com/t/how-to-set-focus-in-form-component/113154/10 "2026-01-08T18:08:06Z")

</div>

I know that in offline mode UI event scripts are not working and I can live with it. But I’m not able to set focus to Form even online.

---

<div class="post-metadata">

**Author:** ![pamato](https://avatars.discourse-cdn.com/v4/letter/p/c68b51/32.png) [@pamato](https://forum.inductiveautomation.com/u/pamato)\
**Post date:** [January 8, 2026, 6:12pm UTC](https://forum.inductiveautomation.com/t/how-to-set-focus-in-form-component/113154/11 "2026-01-08T18:12:39Z")

</div>

Currently, there is not a way to handle this scenario (set focus to a specific field on load or field change) in the Form Component. I’ll get a feature request written up to add this functionality.
