# When a condition is met, a cursor should appear in the text field

**URL:** <https://forum.inductiveautomation.com/t/when-a-condition-is-met-a-cursor-should-appear-in-the-text-field/81136>\
**Category:** Ignition\
**Tags:** perspective\
**Created:** [October 29, 2023, 4:09pm UTC](https://forum.inductiveautomation.com/t/when-a-condition-is-met-a-cursor-should-appear-in-the-text-field/81136 "2023-10-29T16:09:10Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Mihaly\_Sztojka](https://avatars.discourse-cdn.com/v4/letter/m/bc79bd/32.png) [@Mihaly\_Sztojka](https://forum.inductiveautomation.com/u/Mihaly_Sztojka)\
**Post date:** [October 29, 2023, 4:09pm UTC](https://forum.inductiveautomation.com/t/when-a-condition-is-met-a-cursor-should-appear-in-the-text-field/81136/1 "2023-10-29T16:09:10Z")

</div>

Hello,  
I would like to control when the cursor should be in the text field by setting the text field visibility condition.  
Is that possible ? somehow fails, however when I put the script for a button event (onActionPerfomed) it works fine.  
Thanks,  
Misi

---

<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:** [October 29, 2023, 4:20pm UTC](https://forum.inductiveautomation.com/t/when-a-condition-is-met-a-cursor-should-appear-in-the-text-field/81136/2 "2023-10-29T16:20:09Z")

</div>

Show us your script. See blow how to post code on this forum.

> [@Wiki - how to post code on this forum](https://forum.inductiveautomation.com/t/wiki-how-to-post-code-on-this-forum/77831):
>
> This thread is intended as a short help file for all those struggling to post formatted code on the forum. Posting formatted code on the forum (and most others) is as simple as selecting the code and pressing the \</\> button. It works the same as applying Bold or Italic styles to your document. It preserves indentation and applies syntax highlighting. [How to post code]

Would it not be better to **enable** the text field rather than set its visibility?

---

<div class="post-metadata">

**Author:** ![Mihaly\_Sztojka](https://avatars.discourse-cdn.com/v4/letter/m/bc79bd/32.png) [@Mihaly\_Sztojka](https://forum.inductiveautomation.com/u/Mihaly_Sztojka)\
**Post date:** [October 29, 2023, 4:44pm UTC](https://forum.inductiveautomation.com/t/when-a-condition-is-met-a-cursor-should-appear-in-the-text-field/81136/3 "2023-10-29T16:44:24Z")

</div>

The texfield visible depends on the transcationTypeId .  
I also tried the sleep function```

```auto
if self.custom.station_data.transactionTypeId == 200:
	self.getChild("root").getChild("TextField_0").focus()

```

```auto

```

---

<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:** [October 29, 2023, 4:50pm UTC](https://forum.inductiveautomation.com/t/when-a-condition-is-met-a-cursor-should-appear-in-the-text-field/81136/4 "2023-10-29T16:50:02Z")

</div>

One way to do it is like this:

- On the text field add a CUSTOM property. For example,  
`custom.transactionTypeId : 0`
- Create a binding on that property to whereever the "200" value is supposed to come from.
- Right-click on the custom property, select Edit Change Script and enter the code below:

```auto
def valueChanged(self, previousValue, currentValue, origin, missedEvents):
	if currentValue.value == 200:
		self.focus()

```

As mentioned previously, I would bind the **enabled** property rather than the visible property in most cases.

---

<div class="post-metadata">

**Author:** ![Mihaly\_Sztojka](https://avatars.discourse-cdn.com/v4/letter/m/bc79bd/32.png) [@Mihaly\_Sztojka](https://forum.inductiveautomation.com/u/Mihaly_Sztojka)\
**Post date:** [October 30, 2023, 1:23pm UTC](https://forum.inductiveautomation.com/t/when-a-condition-is-met-a-cursor-should-appear-in-the-text-field/81136/5 "2023-10-30T13:23:11Z")

</div>

> [@Transistor](#):
>
> ```auto
> def valueChanged(self, previousValue, currentValue, origin, missedEvents):
> if currentValue.value == 200:
> self.focus()
> 
> ```

Thank you very much!!  
can i disable the focus?  
Have found here : self.blur()  
but for it i have an error message:' object has no attribute 'blur'

---

<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:** [October 30, 2023, 2:14pm UTC](https://forum.inductiveautomation.com/t/when-a-condition-is-met-a-cursor-should-appear-in-the-text-field/81136/6 "2023-10-30T14:14:23Z")

</div>

I don't know, but I suspect that the focus has to be set on something rather than nothing. Try putting it back on the button, or something else.
