# Adding default onClick script to perspective component

**URL:** <https://forum.inductiveautomation.com/t/adding-default-onclick-script-to-perspective-component/90925>\
**Category:** Module Development\
**Tags:** perspective\
**Created:** [May 26, 2024, 11:32pm UTC](https://forum.inductiveautomation.com/t/adding-default-onclick-script-to-perspective-component/90925 "2024-05-26T23:32:37Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Phillip\_Wu](https://avatars.discourse-cdn.com/v4/letter/p/f4b2a3/32.png) [@Phillip\_Wu](https://forum.inductiveautomation.com/u/Phillip_Wu)\
**Post date:** [May 26, 2024, 11:32pm UTC](https://forum.inductiveautomation.com/t/adding-default-onclick-script-to-perspective-component/90925/1 "2024-05-26T23:32:37Z")

</div>

Hi!

I am making some buttons as perspective components and need them to by default call a project library function when clicked. I want to do this by adding a default onClick() script to it's Mouse onClick event, such that when you right click on the component and click Configure Event the script would appear by default.

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

Is this possible to achieve? If not are there any other way to do this?

---

<div class="post-metadata">

**Author:** ![pturmel](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/pturmel/32/3295_2.png) [@pturmel](https://forum.inductiveautomation.com/u/pturmel)\
**Post date:** [May 26, 2024, 11:51pm UTC](https://forum.inductiveautomation.com/t/adding-default-onclick-script-to-perspective-component/90925/2 "2024-05-26T23:51:45Z")

</div>

This is a really bad idea that will produce utterly unmaintainable projects. Module-provided components should never call scripts, or "preset" anything that is normally set by the designer.

Just build into your component whatever default actions you need, in java or javascript (or both), not jython, and offer a boolean component property that enables/disables that functionality.
