How Do I Add An Action Script To A Button

DGH 2.5 now comes with a collection of Action Scripts. These scripts accomplish common tasks developers may want to perform on a data grid. In this example we will see how to use DGH to select a button and associate it to an action script to create a new row in a data grid.


For this example, we will need a stack containing a data grid and a + button.

Create a new stack, drag a data grid on to it as well as a ‘rectangle button’.

Modify the properties of the button (make it narrower) and enter the plus “+” as its label.

Using LiveCode’s IDE or DGH, add three columns to the data grid.

If you haven’t already done so, open DGH by double-clicking the data grid and then, in DGH’s Table Property's view, expand the Action Scripts topic.

Open The Control Picker

In the Add Row line of the Action Scripts topic, click on the ... button (1) to open the Control Picker (2).

Click on the Choose button to enter control selection mode.

Linking To The + Button

Move the mouse over the + button.

DGH displays a tooltip informing you that the button is eligible for selection as the action script’s control. (1)

Note the Control Picker now displays a Cancel button to enable you to back out of this process. (2)

Select The + Button

Click on the + button to select it.

The Control Picker window now displays a Confirm button. (1)

Click the Confirm button to link the data grid, Add Row action script and + button together. (2)

The long id of the button linked to the data grid is now displayed inside the property value for the Add Row line

Testing The + Button

Select the LiveCode Browse tool and click on the + button.

A row will be added to the data grid (the first, in this example) and the first cell is open for entry.


Add your comment

This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.