# This actionPerformed button script causes the next rightmost component to be set active after it is clicked, and I can't figure out why

**URL:** <https://forum.inductiveautomation.com/t/this-actionperformed-button-script-causes-the-next-rightmost-component-to-be-set-active-after-it-is-clicked-and-i-cant-figure-out-why/80112>\
**Category:** Ignition\
**Tags:** vision\
**Created:** [October 5, 2023, 9:53pm UTC](https://forum.inductiveautomation.com/t/this-actionperformed-button-script-causes-the-next-rightmost-component-to-be-set-active-after-it-is-clicked-and-i-cant-figure-out-why/80112 "2023-10-05T21:53:53Z")\
**Posts on this page:** 6\
**Page:** 2

<div class="post-metadata">

**Author:** ![Kevin.Herron](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/kevin.herron/32/7259_2.png) [@Kevin.Herron](https://forum.inductiveautomation.com/u/Kevin.Herron)\
**Post date:** [October 10, 2023, 1:30pm UTC](https://forum.inductiveautomation.com/t/this-actionperformed-button-script-causes-the-next-rightmost-component-to-be-set-active-after-it-is-clicked-and-i-cant-figure-out-why/80112/21 "2023-10-10T13:30:48Z")

</div>

The _maybe_ in this case becomes more likely to (appear to) work because he's doing all this from the Vision Client, which means you have to factor client \<-\> gateway comms into the timing uncertainty.

Regardless, it's certainly not advisable.

---

<div class="post-metadata">

**Author:** ![justinedwards.jle](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/justinedwards.jle/32/37854_2.png) [@justinedwards.jle](https://forum.inductiveautomation.com/u/justinedwards.jle)\
**Post date:** [October 10, 2023, 1:44pm UTC](https://forum.inductiveautomation.com/t/this-actionperformed-button-script-causes-the-next-rightmost-component-to-be-set-active-after-it-is-clicked-and-i-cant-figure-out-why/80112/22 "2023-10-10T13:44:36Z")

</div>

Ah; I see. This is the root cause of his professed latency and the resultant need for an asynchronous call.

---

<div class="post-metadata">

**Author:** ![sherman](https://avatars.discourse-cdn.com/v4/letter/s/e5b9ba/32.png) [@sherman](https://forum.inductiveautomation.com/u/sherman)\
**Post date:** [October 10, 2023, 8:13pm UTC](https://forum.inductiveautomation.com/t/this-actionperformed-button-script-causes-the-next-rightmost-component-to-be-set-active-after-it-is-clicked-and-i-cant-figure-out-why/80112/23 "2023-10-10T20:13:27Z")

</div>

> I see nothing in the code sample provided that is related to changing the position field.

That's because that textbox is bound to a tag that is not directly touched by this script -- when a move command is sent and exectued by the PLC, the motor controller itself will emit a different position value (once it moves). The point was that it was not allowing the text field to update with the correct value, as it was being attached to the active cursor which evidently has higher edit priority than the binding (which makes sense, I just didn't know why it was being selected).

---

<div class="post-metadata">

**Author:** ![sherman](https://avatars.discourse-cdn.com/v4/letter/s/e5b9ba/32.png) [@sherman](https://forum.inductiveautomation.com/u/sherman)\
**Post date:** [October 10, 2023, 8:15pm UTC](https://forum.inductiveautomation.com/t/this-actionperformed-button-script-causes-the-next-rightmost-component-to-be-set-active-after-it-is-clicked-and-i-cant-figure-out-why/80112/24 "2023-10-10T20:15:26Z")

</div>

Oh I am sure it works, but it is quite slow -- hence the original reason I needed to move all of this to an async function (something I will use more of in the future by default). I agree that the slow comms are why it works, and I will be improving the PLC interfacing in the future to ensure that it functions correctly even if we get a faster controller.

---

<div class="post-metadata">

**Author:** ![justinedwards.jle](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/justinedwards.jle/32/37854_2.png) [@justinedwards.jle](https://forum.inductiveautomation.com/u/justinedwards.jle)\
**Post date:** [October 11, 2023, 2:36am UTC](https://forum.inductiveautomation.com/t/this-actionperformed-button-script-causes-the-next-rightmost-component-to-be-set-active-after-it-is-clicked-and-i-cant-figure-out-why/80112/25 "2023-10-11T02:36:27Z")

</div>

> [@sherman](#):
>
> That's because that textbox is bound to a tag that is not directly touched by this script

I see; the binding is not responding as expected to this unusual approach. You can always refresh a binding using [system.db.refresh](https://docs.inductiveautomation.com/display/DOC81/system.db.refresh). Until you can develop a more efficient way to go about this, you can probably at least get the textfield to update by adding this to the end of your asynchronous function:

```auto
def updateTextfield():
	component = # Put relative path to textfield here
	propertyName = 'text'
	system.db.refresh(component, propertyName)
system.util.invokeLater(updateTextfield)

```

---

<div class="post-metadata">

**Author:** ![sherman](https://avatars.discourse-cdn.com/v4/letter/s/e5b9ba/32.png) [@sherman](https://forum.inductiveautomation.com/u/sherman)\
**Post date:** [October 11, 2023, 6:25pm UTC](https://forum.inductiveautomation.com/t/this-actionperformed-button-script-causes-the-next-rightmost-component-to-be-set-active-after-it-is-clicked-and-i-cant-figure-out-why/80112/26 "2023-10-11T18:25:12Z")

</div>

Thank you, the force update code will be helpful. Hopefully I don't need it in this particular case once the gui traversal is fixed but I know I'll need it elsewhere.

[Previous page](https://forum.inductiveautomation.com/t/this-actionperformed-button-script-causes-the-next-rightmost-component-to-be-set-active-after-it-is-clicked-and-i-cant-figure-out-why/80112.md?page=1)
