Interface

# ActionSource

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

## Description

The <span class="title-ref">ActionSource</span> interface is implemented by `Timer</api/language/timer>`, `DesktopBevelButton</api/user_interface/desktop/desktopbevelbutton>` and `DesktopButton</api/user_interface/desktop/desktopbutton>`. An <span class="title-ref">ActionSource</span> object calls the PerformAction method of each `ActionNotificationReceiver</api/language/actionnotificationreceiver>` registered with it.

## Methods

<div class="rst-class">

table-centered_column_4

</div>

| Name                                                                              | Parameters                                                                         | Returns | Shared |
|-----------------------------------------------------------------------------------|------------------------------------------------------------------------------------|---------|--------|
| `AddActionNotificationReceiver<actionsource.addactionnotificationreceiver>`       | receiver As `ActionNotificationReceiver</api/language/actionnotificationreceiver>` |         |        |
| `RemoveActionNotificationReceiver<actionsource.removeactionnotificationreceiver>` | receiver As `ActionNotificationReceiver</api/language/actionnotificationreceiver>` |         |        |

## Method descriptions

<div id="actionsource.addactionnotificationreceiver">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

ActionSource.AddActionNotificationReceiver

**AddActionNotificationReceiver**(receiver As `ActionNotificationReceiver</api/language/actionnotificationreceiver>`)

> Registers an `ActionNotificationReceiver</api/language/actionnotificationreceiver>`.

<div id="actionsource.removeactionnotificationreceiver">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

ActionSource.RemoveActionNotificationReceiver

**RemoveActionNotificationReceiver**(receiver As `ActionNotificationReceiver</api/language/actionnotificationreceiver>`)

> Unregisters an ActionNotificationReceiver.

## Notes

If you implement this interface in your application, you must implement the methods with the parameters as shown here.

## Sample code

If you want to have a Button call PerformAction on an `ActionNotificationReceiver</api/language/actionnotificationreceiver>` then you would create a new class (perhaps ActionNotificationTest) that implements `ActionNotificationReceiver</api/language/actionnotificationreceiver>`. In the PerformAction method, you add the code you want to run when the button is pressed (and before `DesktopButton.Pressed<desktopbutton.pressed>` event is called). For example:

``` xojo
MessageBox("PerformAction called.")
```

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

Now in the `Opening<desktopcontrol.opening>` event handler for a DesktopButton, you can add your receiver:

``` xojo
Var action As New ActionNotificationTest
Me.AddActionNotificationReceiver(action)
```

## Compatibility

|                       |                       |
|-----------------------|-----------------------|
| **Project Types**     | Console, Desktop, Web |
| **Operating Systems** | All                   |
