# OnClick

The **OnClick** event is the main entry point for a [script function](../../../scripting/script_functions).

| **Method Name:**   | OnClick                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              |
| ------------------ | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| **Argument Type:** | [**ClickData**](../scripting_objects/clickdata)                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      |
| **Return Type:**   | _none_                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               |
| **Description:**   | <p>This method is called whenever a button or hotkey containing a <a href="../../../scripting/script_functions">script function</a>is run. The <strong>ClickData</strong> object provides useful information about the command environment, including source and destination tabs and paths, any selected files, command line arguments, any qualifier keys that were held down, etc. This information is all accessible from the <strong>ClickData.func</strong> property (which returns a <a href="../scripting_objects/func"><strong>Func</strong></a> object).<br>Note that when a script function is run, any instructions not contained inside a function are executed first, before <strong>OnClick</strong> is invoked. This means that the <strong>OnClick</strong> method is technically optional (as you could just implement the entire script outside of a function), although it is recommended that you implement it simply for the benefit of the <strong>ClickData</strong> object it receives.</p> |
