# Text Field focus shows old value after clearing

**URL:** <https://forum.inductiveautomation.com/t/text-field-focus-shows-old-value-after-clearing/110512>\
**Category:** Ignition\
**Tags:** perspective\
**Created:** [September 10, 2025, 2:21pm UTC](https://forum.inductiveautomation.com/t/text-field-focus-shows-old-value-after-clearing/110512 "2025-09-10T14:21:03Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![TechEnlive](https://avatars.discourse-cdn.com/v4/letter/t/3be4f8/32.png) [@TechEnlive](https://forum.inductiveautomation.com/u/TechEnlive)\
**Post date:** [September 10, 2025, 2:21pm UTC](https://forum.inductiveautomation.com/t/text-field-focus-shows-old-value-after-clearing/110512/1 "2025-09-10T14:21:03Z")

</div>

Hi everyone,

I have a Text Field in Perspective that I want to focus when a button is clicked. On the button click, I call a handler that is associated with the Text Field. Inside that handler, I use:

```python
self.focus()

```

The field does receive focus correctly, but the problem is that it still shows the previous value.

on button click

```python
def runAction(self, event):
		
	self.getSibling("txt_user").props.text=""	
	system.perspective.sendMessage("focustxt_user", scope="page")

```

Has anyone run into this issue before? How can I reliably clear the text box and set focus to it when clicking the button?

---

<div class="post-metadata">

**Author:** ![Transistor](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/transistor/32/3380_2.png) [@Transistor](https://forum.inductiveautomation.com/u/Transistor)\
**Post date:** [September 10, 2025, 2:26pm UTC](https://forum.inductiveautomation.com/t/text-field-focus-shows-old-value-after-clearing/110512/2 "2025-09-10T14:26:05Z")

</div>

I'd start by moving the text deletion into the message handler. That will get rid of all the `getSibling` syntax which breaks when you move components in and out of containers. (It's one of the benefits of using message handlers in the first place.)

I suspect that `scope = 'view'` would be adequate too.

---

<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:** [September 10, 2025, 2:27pm UTC](https://forum.inductiveautomation.com/t/text-field-focus-shows-old-value-after-clearing/110512/3 "2025-09-10T14:27:03Z")

</div>

Most likely, the text field is set to reject updates while editing (focused). Assignments to Perspective properties from scripts are not synchronous, so the focus might be reaching the field before the assignment.

(I probably wouldn't use a message if you have a reference to the component--you can use `.focus()` on that reference.)

---

<div class="post-metadata">

**Author:** ![TechEnlive](https://avatars.discourse-cdn.com/v4/letter/t/3be4f8/32.png) [@TechEnlive](https://forum.inductiveautomation.com/u/TechEnlive)\
**Post date:** [September 10, 2025, 2:31pm UTC](https://forum.inductiveautomation.com/t/text-field-focus-shows-old-value-after-clearing/110512/4 "2025-09-10T14:31:01Z")

</div>

Hi,

Fist thanks for helping.  
i have used .focus() as you said but it did not effect any.

```python
def runAction(self, event):
	
		
	self.getSibling("txt_user").props.text=""	
	self.getSibling("txt_user").focus()

```

---

<div class="post-metadata">

**Author:** ![TechEnlive](https://avatars.discourse-cdn.com/v4/letter/t/3be4f8/32.png) [@TechEnlive](https://forum.inductiveautomation.com/u/TechEnlive)\
**Post date:** [September 10, 2025, 2:31pm UTC](https://forum.inductiveautomation.com/t/text-field-focus-shows-old-value-after-clearing/110512/5 "2025-09-10T14:31:51Z")

</div>

Hi,  
i have changed but still same.

```python
system.perspective.sendMessage("focustxt_user", scope="view")

```

---

<div class="post-metadata">

**Author:** ![Transistor](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/transistor/32/3380_2.png) [@Transistor](https://forum.inductiveautomation.com/u/Transistor)\
**Post date:** [September 10, 2025, 2:37pm UTC](https://forum.inductiveautomation.com/t/text-field-focus-shows-old-value-after-clearing/110512/6 "2025-09-10T14:37:27Z")

</div>

Duplicate the view, strip out everything except the text field and the button. In Project Browser, right-click, Copy JSON, and paste the code here. [Wiki - how to post code on this forum](https://forum.inductiveautomation.com/t/wiki-how-to-post-code-on-this-forum/77831).

---

<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:** [September 10, 2025, 2:39pm UTC](https://forum.inductiveautomation.com/t/text-field-focus-shows-old-value-after-clearing/110512/7 "2025-09-10T14:39:13Z")

</div>

Did you set `rejectUpdatesWhileFocused` to false?

---

<div class="post-metadata">

**Author:** ![TechEnlive](https://avatars.discourse-cdn.com/v4/letter/t/3be4f8/32.png) [@TechEnlive](https://forum.inductiveautomation.com/u/TechEnlive)\
**Post date:** [September 10, 2025, 2:43pm UTC](https://forum.inductiveautomation.com/t/text-field-focus-shows-old-value-after-clearing/110512/8 "2025-09-10T14:43:06Z")

</div>

Hi,  
Thanks a lot. It was set true i just set false and its working…

Thanks agian.
