# Mouse clicked on a script button

**URL:** <https://forum.inductiveautomation.com/t/mouse-clicked-on-a-script-button/43778>\
**Category:** Ignition\
**Tags:** ignition80\
**Created:** [February 24, 2021, 11:16am UTC](https://forum.inductiveautomation.com/t/mouse-clicked-on-a-script-button/43778 "2021-02-24T11:16:26Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![gmiroclosa](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/gmiroclosa/32/21572_2.png) [@gmiroclosa](https://forum.inductiveautomation.com/u/gmiroclosa)\
**Post date:** [February 24, 2021, 11:16am UTC](https://forum.inductiveautomation.com/t/mouse-clicked-on-a-script-button/43778/1 "2021-02-24T11:16:26Z")

</div>

Hi,  
I wrote the code:  
button = event.source.parent.getComponent(“BUTTON\_X”)  
button.doClick()

And ok, it works.  
But, If I want the  
button.mouseRelease() ¿?¿?¿  
Is there any solution to call to mouseRelease event from the script?¿  
Thanks in advance,  
Guillem

---

<div class="post-metadata">

**Author:** ![dkhayes117](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/dkhayes117/32/68344_2.png) [@dkhayes117](https://forum.inductiveautomation.com/u/dkhayes117)\
**Post date:** [February 24, 2021, 4:19pm UTC](https://forum.inductiveautomation.com/t/mouse-clicked-on-a-script-button/43778/2 "2021-02-24T16:19:59Z")

</div>

As far as I know, you can’t **easily** invoke a mouse release event on a button virtually. In my opinion, it sounds like you need to rethink your methodology. If you need to call a script from other places than the button that has the script, you need to move it to a project script then call it from where ever you need it.

---

<div class="post-metadata">

**Author:** ![bkarabinchak.psi](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/bkarabinchak.psi/32/83567_2.png) [@bkarabinchak.psi](https://forum.inductiveautomation.com/u/bkarabinchak.psi)\
**Post date:** [February 24, 2021, 6:17pm UTC](https://forum.inductiveautomation.com/t/mouse-clicked-on-a-script-button/43778/3 "2021-02-24T18:17:42Z")

</div>

Listen to @dkhayes117

What you’re describing - all the logic being on a GUI component - is known as the [Magic Push Button](https://en.wikipedia.org/wiki/Magic_pushbutton) anti-pattern.

It’s a huge personal pet peeve of mine after cleaning up a bunch of them.

---

<div class="post-metadata">

**Author:** ![gmiroclosa](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/gmiroclosa/32/21572_2.png) [@gmiroclosa](https://forum.inductiveautomation.com/u/gmiroclosa)\
**Post date:** [February 25, 2021, 8:08am UTC](https://forum.inductiveautomation.com/t/mouse-clicked-on-a-script-button/43778/4 "2021-02-25T08:08:48Z")

</div>

Thanks to all,  
Finally I put the script code into button / actionPerformed and It works for me with the action .doclick().  
Ok, I didn’t know that I couldn’t call a mouse button click from the script.
