# Perspective Textfield not getting focus after setting display True

**URL:** <https://forum.inductiveautomation.com/t/perspective-textfield-not-getting-focus-after-setting-display-true/53949>\
**Category:** Ignition\
**Created:** [December 9, 2021, 4:48pm UTC](https://forum.inductiveautomation.com/t/perspective-textfield-not-getting-focus-after-setting-display-true/53949 "2021-12-09T16:48:38Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Jonathan](https://avatars.discourse-cdn.com/v4/letter/j/aeb1de/32.png) [@Jonathan](https://forum.inductiveautomation.com/u/Jonathan)\
**Post date:** [December 9, 2021, 4:48pm UTC](https://forum.inductiveautomation.com/t/perspective-textfield-not-getting-focus-after-setting-display-true/53949/1 "2021-12-09T16:48:38Z")

</div>

I have a Textfield with a message handler on it. The message handler sets the display property of the Textfield to True and then calls self.focus(). The problem is the Textfield does not seem to be getting focus after the handler runs.

If i change the Textfield’s display property to always be True, the the handler’s focus seems to work fine. Do I some how need to put in a delay for the Textfield to become True first then run a script to set focus on the Textfield?

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

---

<div class="post-metadata">

**Author:** ![YF129701](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/yf129701/32/60498_2.png) [@YF129701](https://forum.inductiveautomation.com/u/YF129701)\
**Post date:** [December 9, 2021, 7:14pm UTC](https://forum.inductiveautomation.com/t/perspective-textfield-not-getting-focus-after-setting-display-true/53949/2 "2021-12-09T19:14:37Z")

</div>

Does some other component receive focus? Is there ever a situation where multiple components receive focus at the same time?

---

<div class="post-metadata">

**Author:** ![Jonathan](https://avatars.discourse-cdn.com/v4/letter/j/aeb1de/32.png) [@Jonathan](https://forum.inductiveautomation.com/u/Jonathan)\
**Post date:** [December 9, 2021, 7:36pm UTC](https://forum.inductiveautomation.com/t/perspective-textfield-not-getting-focus-after-setting-display-true/53949/3 "2021-12-09T19:36:31Z")

</div>

no, I only have a button and this textfield. This text field is the only thing setup to call self.focus()

---

<div class="post-metadata">

**Author:** ![YF129701](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/yf129701/32/60498_2.png) [@YF129701](https://forum.inductiveautomation.com/u/YF129701)\
**Post date:** [December 9, 2021, 7:48pm UTC](https://forum.inductiveautomation.com/t/perspective-textfield-not-getting-focus-after-setting-display-true/53949/4 "2021-12-09T19:48:12Z")

</div>

Ok, I verified this behavior and it does seem to be a timing issue. I tested your script but with 1/8th of a second delay and the focus behaved normally.

```python
import time

self.position.display = True
time.sleep(0.125)
self.focus()

```

The effect is close to what you want. You may be able to get an even faster focus.

By the way, if anyone else was wondering, the same thing happens when using `meta.visible` instead of `position.display` - the text field will still not focus.

**EDIT:** I’m not saying this is the solution, this is only a simple test. I don’t know what’s actually causing this behavior. It might have to do with multithreading or some race conditions.
