Adding default onClick script to perspective component


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.

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

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.