# Scripting Events

Events are functions in a script file that are called by Opus at various times. There are three main classes of events:

* Most events are [script add-in](../../scripting/script_add-ins) events - they are called whenever various events or activities occur. For example, the [**OnBeforeFolderChange**](scripting_events/onbeforefolderchange) event is called before the folder is changed in a tab. Which events a script add-in listens for is completely defined by the script - simply implement the appropriate method and Opus will call it at the appropriate time.
* [Script functions](../../scripting/script_functions) are called via their [**OnClick**](scripting_events/onclick) event - although implementing this method is optional, as the entire script is executed when a script button or hotkey is run. The advantage of implementing **OnClick** is the [**ClickData**](https://github.com/Chaoses-Ib/DirectoryOpus/blob/main/Manual/reference/scripting_reference/scripting_events/scripting_objects/clickdata.md) object passed to the method which can provide useful information about the command's environment.
* [Rename scripts](../../scripting/rename_scripts) provide an event that's called for each file being renamed. For historical reasons, there are a number of different rename events that can be implemented - the simplest and recommended is the [**OnGetNewName**](scripting_events/ongetnewname) event.

With the exception of the legacy rename events (**Rename\_GetNewName** and **Rename\_GetNewName2**), all event functions have a single argument - an event-specific data object that's passed from Opus to the script each time the event is called. Each object contains properties (and sometimes methods) relevant to the event. The advantage of using a single object is that in the future additional properties can be added without changing the function signature of the event itself.
