# Trigger onActionPerformed from another component

**URL:** <https://forum.inductiveautomation.com/t/trigger-onactionperformed-from-another-component/97771>\
**Category:** Ignition\
**Created:** [October 25, 2024, 1:57pm UTC](https://forum.inductiveautomation.com/t/trigger-onactionperformed-from-another-component/97771 "2024-10-25T13:57:50Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![hw79](https://avatars.discourse-cdn.com/v4/letter/h/838e76/32.png) [@hw79](https://forum.inductiveautomation.com/u/hw79)\
**Post date:** [October 25, 2024, 1:57pm UTC](https://forum.inductiveautomation.com/t/trigger-onactionperformed-from-another-component/97771/1 "2024-10-25T13:57:50Z")

</div>

I want to trigger the onActionPerformed event on a button when onKeyUp == 'Enter' on a Text Field component. Is this possible? I was thinking message handler, but I don't know what the function would be to trigger the action. `self.onActionPerformed()`?

---

<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:** [October 25, 2024, 2:08pm UTC](https://forum.inductiveautomation.com/t/trigger-onactionperformed-from-another-component/97771/2 "2024-10-25T14:08:03Z")

</div>

I don't know that you can call `onActionPerformed` directly, but you can right click on a component -\> Configure Scripts and add a method:

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

Then, you'll be able to call that method from anywhere on that view.

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

So, what you can do is move your `onActionPerformed` logic to one or more component methods, then on the Button that has the method, you would just call it using

```python
self.printMessage('hello') # replace with your method

```

That way, your logic is in one place if you need to modify it and you have the ability to execute code within a view. If you need to communicate within a view, I would stay away from view-scoped message handlers and use only component methods.

---

<div class="post-metadata">

**Author:** ![hw79](https://avatars.discourse-cdn.com/v4/letter/h/838e76/32.png) [@hw79](https://forum.inductiveautomation.com/u/hw79)\
**Post date:** [October 25, 2024, 2:29pm UTC](https://forum.inductiveautomation.com/t/trigger-onactionperformed-from-another-component/97771/3 "2024-10-25T14:29:51Z")

</div>

perfect, this is what I was looking for, thanks!
