## Action

Actions can be attached to any widget so that actions can be executed from that widget. They are configured from the `Actions` Property. There are several types of actions that can be associated with any type of widget. You may also add customzied action through Eclipse plugin mechanism.

- Open OPI
    Open a related OPI. If `Repalce` is selected, it will replace the current OPI. You can send macros to the OPI to be opened by setting the `Macros` property. If a widget has this action hooked to its mouse click event, user will also be able to open the related OPI from its context menu: `Open`, `Open in New Tab` or `Open in New Window`. Or user can hold the `Ctrl`/`Shift` key while clicking on the widget to open the related OPI in new Tab/Window.
- Open OPI in View
    Open an OPI in view. The view can be place in five possible positions: Left, Right, Top, Bottom or Detached. An undetached View can also be detached as standalone window floating on top by right clicking the view tab and click `Detached`. By clicking `Detached` again, you can put it back to the workbench window.
- Write PV
    Write a PV.
- Execute Command
    Execute system command just as executing command from shell or command line on Windows. The command should be searchable from system PATH, otherwise, it should be a full path to the command. The output will be displayed in the console if there is. The property "Command Directory" is where the command will be executed. In most cases, you can just use the default directory which is user's home directory.
- Execute JavaScript
    Execute a Javascript file, in which there are two accessible objects: `widget` and `display` so that you can access the widget or the display. See Access Widget
- Execute Python Script
    Execute a Python script file, in which there are two accessible objects: `widget` and `display` so that you can access the widget or the display. See Access Widget
- Play WAV file
    Play a sound file in WAV format.
- Open File
    Open a file with the default editor. For example, you can open a databrowser file in databrowser.
- Open Webpage
    Open a webpage in system default web browser.

### Configure Actions

Actions are configured from the `Actions` property of widget. The first action can be hooked with the mouse click event, which means clicking on the widget at Runtime will execute the first action.

### Invoke Action at Runtime

At Runtime, you can execute an action by right clicking on the widget and selecting the action from `Actions` submenu. If you selected the option `Hook the first action to the mouse click event on widget` in the actions config dialog, you can simply execute the first action by clicking on the widget.

Actions may also be invoked from script by calling the method executeAction. For example:

    widget.executeAction(0); //execute the first attached action