# system.util.invokeLater()

**URL:** <https://forum.inductiveautomation.com/t/system-util-invokelater/41663>\
**Category:** Ignition\
**Created:** [December 18, 2020, 10:03pm UTC](https://forum.inductiveautomation.com/t/system-util-invokelater/41663 "2020-12-18T22:03:56Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![ken.maze](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/ken.maze/32/85876_2.png) [@ken.maze](https://forum.inductiveautomation.com/u/ken.maze)\
**Post date:** [December 18, 2020, 10:03pm UTC](https://forum.inductiveautomation.com/t/system-util-invokelater/41663/1 "2020-12-18T22:03:56Z")

</div>

Hi,

I am wanting to hide w text field until I need it, then make it visible and put it into focus. I am attempting to follow the advice at

[https://docs.inductiveautomation.com/display/DOC80/Focus+Manipulation#FocusManipulation-AboutInvokeLater](https://docs.inductiveautomation.com/display/DOC80/Focus+Manipulation#FocusManipulation-AboutInvokeLater)

I made a button on the page, with the following code attached in the onActionPerformed event handler

```
self.getSibling("Serial1").meta.visible = 1

def focus():
    event.source.parent.getComponent('Serial1').requestFocusInWindow()
 
# Call the function once the event has executed.
import system
logger = system.util.getLogger("Ship_Logger")
logger.info("Invoking later " )
system.util.invokeLater(focus)

```

I keep getting an error

Error running action ‘component.onActionPerformed’ on ShipConfirm@C/root/Button: Traceback (most recent call last): File “function:runAction”, line 13, in runAction AttributeError: ‘com.inductiveautomation.ignition.common.script.Imm’ object has no attribute ‘invokeLater’

when I try to invoke this. I have tried commenting out various pieces, using import system in various places, etc etc. Using 8.0.14 on Windows. Any advice?

Thanks

---

<div class="post-metadata">

**Author:** ![paul-griffith](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/paul-griffith/32/37249_2.png) [@paul-griffith](https://forum.inductiveautomation.com/u/paul-griffith)\
**Post date:** [December 18, 2020, 10:06pm UTC](https://forum.inductiveautomation.com/t/system-util-invokelater/41663/2 "2020-12-18T22:06:41Z")

</div>

`invokeLater` is only applicable to Vision; Perspective’s single-threaded GUI is running on the frontend, separate from your script’s execution context. `requestFocusInWindow()` also won’t work - instead, each component has a `focus()` method that will _attempt_ to call focus to itself.

---

<div class="post-metadata">

**Author:** ![ken.maze](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/ken.maze/32/85876_2.png) [@ken.maze](https://forum.inductiveautomation.com/u/ken.maze)\
**Post date:** [December 18, 2020, 10:34pm UTC](https://forum.inductiveautomation.com/t/system-util-invokelater/41663/3 "2020-12-18T22:34:39Z")

</div>

ok, I didn’t see anything in the help text that said it was only for Vision, thanks for the help.

What I’m hearing is that there is no way in Perspective to tell focus to go to some particular object without that object having an event invoked that can call the `focus()` method. I can’t say “I want that object to get focus”, only that “I want focus”. Correct?

And there is no event I can see that would be called if I just made the text field visible. Nor can I see any other event that would be applicable to be called from another perspective component. Correct?

Thanks  
Ken

---

<div class="post-metadata">

**Author:** ![paul-griffith](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/paul-griffith/32/37249_2.png) [@paul-griffith](https://forum.inductiveautomation.com/u/paul-griffith)\
**Post date:** [December 18, 2020, 10:47pm UTC](https://forum.inductiveautomation.com/t/system-util-invokelater/41663/4 "2020-12-18T22:47:06Z")

</div>

> [@ken.maze](#):
>
> ok, I didn’t see anything in the help text that said it was only for Vision, thanks for the help.

In the manual's defense, it's in a 'Scripting in Vision' category, but, yeah, some of the manual is still using old copy from when we only had one visualization system.

> [@ken.maze](#):
>
> What I’m hearing is that there is no way in Perspective to tell focus to go to some particular object without that object having an event invoked that can call the `focus()` method. I can’t say “I want that object to get focus”, only that “I want focus”. Correct?

Not exactly - you just need a reference to the other component. So you can either broadcast a message, and have a handler on the target component (preferred) or you can do the same thing you'd do in Vision - walk up/down/sideways on the component tree to get to a desired component:  
[https://docs.inductiveautomation.com/display/DOC80/Perspective+Component+Methods#PerspectiveComponentMethods-ObjectTraversal](https://docs.inductiveautomation.com/display/DOC80/Perspective+Component+Methods#PerspectiveComponentMethods-ObjectTraversal)

Once you _have_ a reference, you just call its `focus()` method; it's basically analogous to the `requestFocusInWindow()` builtin Swing method you would call in Vision.

> [@ken.maze](#):
>
> And there is no event I can see that would be called if I just made the text field visible. Nor can I see any other event that would be applicable to be called from another perspective component. Correct?

You can add a property change script (right click) to the component's visible (or any other) property.

---

<div class="post-metadata">

**Author:** ![ken.maze](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/ken.maze/32/85876_2.png) [@ken.maze](https://forum.inductiveautomation.com/u/ken.maze)\
**Post date:** [December 18, 2020, 10:59pm UTC](https://forum.inductiveautomation.com/t/system-util-invokelater/41663/5 "2020-12-18T22:59:10Z")

</div>

Yes, I see that there is a separate Perspective page on methods.

I will give that a shot and let you know how it goes. Thanks for the help!

Ken

---

<div class="post-metadata">

**Author:** ![ken.maze](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/ken.maze/32/85876_2.png) [@ken.maze](https://forum.inductiveautomation.com/u/ken.maze)\
**Post date:** [December 30, 2020, 6:49pm UTC](https://forum.inductiveautomation.com/t/system-util-invokelater/41663/6 "2020-12-30T18:49:27Z")

</div>

Thanks, I got it figured out. i was having problems understanding that I could reference something that wasn’t a property eg self.getSibling(“Label\_1”)
