# Auto Advance Entry Field Focus in Perspective

**URL:** <https://forum.inductiveautomation.com/t/auto-advance-entry-field-focus-in-perspective/49556>\
**Category:** Ignition\
**Tags:** ignition80, perspective\
**Created:** [August 4, 2021, 2:37pm UTC](https://forum.inductiveautomation.com/t/auto-advance-entry-field-focus-in-perspective/49556 "2021-08-04T14:37:57Z")\
**Posts on this page:** 11\
**Page:** 1

<div class="post-metadata">

**Author:** ![pkhoshroo](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/pkhoshroo/32/26801_2.png) [@pkhoshroo](https://forum.inductiveautomation.com/u/pkhoshroo)\
**Post date:** [August 4, 2021, 2:37pm UTC](https://forum.inductiveautomation.com/t/auto-advance-entry-field-focus-in-perspective/49556/1 "2021-08-04T14:37:57Z")

</div>

Hello everyone,

I am new to perspective and I am trying to shift focus to different numeric entry fields:  
So I have 5 numeric fields for 5 barcode values. Is it possible to shift the focus to the next field in such a way where there would be 5 separate scans displayed?  
 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/4/b/4b4833ceed9fd2b1468be57faca819df3879d1d7.png)

I found a property change script here:

> [@Shifting Entry Field Focus](https://forum.inductiveautomation.com/t/shifting-entry-field-focus/29651):
>
> I am trying to shift focus to the next data entry field, after a value is entered for an initial field. The code below works for a keyboard, but the touch screen mode entry pad leaves a blinking line in the field even after it loses focus. Is there a way around this? On property change: if event.propertyName == 'doubleValue': nextfield = event.source.parent.getComponent('Next Component Name') nextfield.requestFocusInWindow()

But it does not work for perspective, I know there might be lots of ways to do that probably using containers or property changes, but not sure how to do it. Any information would be much appreciated!

---

<div class="post-metadata">

**Author:** ![nminchin](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/nminchin/32/6911_2.png) [@nminchin](https://forum.inductiveautomation.com/u/nminchin)\
**Post date:** [August 4, 2021, 3:06pm UTC](https://forum.inductiveautomation.com/t/auto-advance-entry-field-focus-in-perspective/49556/2 "2021-08-04T15:06:50Z")

</div>

Try this  
[https://docs.inductiveautomation.com/display/DOC80/Perspective+Component+Methods#PerspectiveComponentMethods-RequestingFocus](https://docs.inductiveautomation.com/display/DOC80/Perspective+Component+Methods#PerspectiveComponentMethods-RequestingFocus)

---

<div class="post-metadata">

**Author:** ![pkhoshroo](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/pkhoshroo/32/26801_2.png) [@pkhoshroo](https://forum.inductiveautomation.com/u/pkhoshroo)\
**Post date:** [August 4, 2021, 3:26pm UTC](https://forum.inductiveautomation.com/t/auto-advance-entry-field-focus-in-perspective/49556/3 "2021-08-04T15:26:54Z")

</div>

Thank you very much for your response!  
Unfortunately, I am not quite sure how to use the information provided in this link to find the answer. In order to advance focus, do I need to create a custom method for each numeric field? and then call them from somewhere else? Where should I use the focus command?

> [@nminchin](#):
>
> [Perspective Component Methods - Ignition User Manual 8.0 - Ignition Documentation](https://docs.inductiveautomation.com/display/DOC80/Perspective+Component+Methods#PerspectiveComponentMethods-RequestingFocus)

This is my first application with perspective so I am not quite sure to use which method exactly. I could not find anything for perspective and I found this link for vision:

> [@Auto advance input field focus after barcode scan](https://forum.inductiveautomation.com/t/auto-advance-input-field-focus-after-barcode-scan/9004/4):
>
> Try something like this: [propertyChange event](https://www.inductiveautomation.com/support/usermanuals/ignition/event_types.htm) if event.propertyName == "text": if chr(13) in event.newValue or chr(10) in event.newValue: event.source.parent.getComponent("txt2").requestFocusInWindow() NOTE TO SELF [size=50](and you since you are reading this)[/size]: PASTING text into a text field does NOT fire the propertyChange event.

---

<div class="post-metadata">

**Author:** ![nminchin](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/nminchin/32/6911_2.png) [@nminchin](https://forum.inductiveautomation.com/u/nminchin)\
**Post date:** [August 4, 2021, 3:50pm UTC](https://forum.inductiveautomation.com/t/auto-advance-entry-field-focus-in-perspective/49556/4 "2021-08-04T15:50:49Z")

</div>

You would do something similar to that vision script, but instead you would attach a [property change event](https://docs.inductiveautomation.com/display/DOC80/Perspective+Property+Change+Scripts)  
script to the props.text prop of each input field and use this as the script:

```auto
if chr(13) in currentValue.value or chr(10) in event.newValue:
    self.getSibling('next input component').focus()

```

You can select the next input component from the property selector. You can’t select a component itself, so you’ll need to select a property of a component and then delete the property name text so you’re left with similar to above code

 ![Screenshot_20210805-011725_Chrome](https://us1.discourse-cdn.com/inductiveautomation/original/3X/d/0/d075f199946de4b1fda4b2f419472283d358019c.jpeg)

---

<div class="post-metadata">

**Author:** ![pkhoshroo](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/pkhoshroo/32/26801_2.png) [@pkhoshroo](https://forum.inductiveautomation.com/u/pkhoshroo)\
**Post date:** [August 4, 2021, 5:33pm UTC](https://forum.inductiveautomation.com/t/auto-advance-entry-field-focus-in-perspective/49556/5 "2021-08-04T17:33:27Z")

</div>

I am not quite sure what is chr(13) and chr(10). Are they being used only for text fields? Or I can use them for numeric field as well? My application has only numeric fields.

Also, I tried this code, and it did not work.

> [@nminchin](#):
>
> ```auto
> if chr(13) in currentValue.value or chr(10) in event.newValue:
> self.getSibling('next input component').focus()
> 
> ```

So what I did was:

1. Created 2 text fields
2. Used edit property change script on the first field
3. I wrote this script:

```auto
	if chr(13) in currentValue.value or chr(10) in event.newValue:
	    self.getSibling("TextField_0").focus()

```

I did the same thing for two numeric fields although I was not sure if I can use the same script, it did not work either. So when the barcode scanner enters the 1st value, the cursor does not automatically go to the 2nd field.

---

<div class="post-metadata">

**Author:** ![pkhoshroo](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/pkhoshroo/32/26801_2.png) [@pkhoshroo](https://forum.inductiveautomation.com/u/pkhoshroo)\
**Post date:** [August 4, 2021, 6:26pm UTC](https://forum.inductiveautomation.com/t/auto-advance-entry-field-focus-in-perspective/49556/6 "2021-08-04T18:26:09Z")

</div>

This is what I did and it worked:

1. Created 2 text fields (tx0, tx1)
2. Used edit property change script on the first field (tx0)
3. I wrote this script:

```auto
	if currentValue!=previousValue:
	    self.getSibling('tx1').focus()

```

---

<div class="post-metadata">

**Author:** ![nminchin](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/nminchin/32/6911_2.png) [@nminchin](https://forum.inductiveautomation.com/u/nminchin)\
**Post date:** [August 4, 2021, 9:05pm UTC](https://forum.inductiveautomation.com/t/auto-advance-entry-field-focus-in-perspective/49556/7 "2021-08-04T21:05:17Z")

</div>

~~Chr(13) is tab and ch(10) is carriage return\* (or line feed… Can’t remember),~~ which are usually what a bar code scanner uses to delimit the end of its code. Glad you got it sorted

---

<div class="post-metadata">

**Author:** ![lrose](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/lrose/32/62724_2.png) [@lrose](https://forum.inductiveautomation.com/u/lrose)\
**Post date:** [August 5, 2021, 11:11am UTC](https://forum.inductiveautomation.com/t/auto-advance-entry-field-focus-in-perspective/49556/8 "2021-08-05T11:11:49Z")

</div>

> [@nminchin](#):
>
> Chr(13) is tab and ch(10) is carriage return\* (or line feed… Can’t remember)

Chr(13) is Carriage Return, also written as `\r`.  
Chr(10) is Line Feed or New Line, also written as `\n`

---

<div class="post-metadata">

**Author:** ![nminchin](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/nminchin/32/6911_2.png) [@nminchin](https://forum.inductiveautomation.com/u/nminchin)\
**Post date:** [August 5, 2021, 11:13am UTC](https://forum.inductiveautomation.com/t/auto-advance-entry-field-focus-in-perspective/49556/9 "2021-08-05T11:13:44Z")

</div>

Whoops! I knew that, tab is chr(9)

---

<div class="post-metadata">

**Author:** ![pkhoshroo](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/pkhoshroo/32/26801_2.png) [@pkhoshroo](https://forum.inductiveautomation.com/u/pkhoshroo)\
**Post date:** [August 5, 2021, 11:59am UTC](https://forum.inductiveautomation.com/t/auto-advance-entry-field-focus-in-perspective/49556/10 "2021-08-05T11:59:02Z")

</div>

Thank you! Could not have done it without your help.

---

<div class="post-metadata">

**Author:** ![pkhoshroo](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/pkhoshroo/32/26801_2.png) [@pkhoshroo](https://forum.inductiveautomation.com/u/pkhoshroo)\
**Post date:** [August 5, 2021, 12:00pm UTC](https://forum.inductiveautomation.com/t/auto-advance-entry-field-focus-in-perspective/49556/11 "2021-08-05T12:00:03Z")

</div>

Thanks for the clarification!
