Actions - UNC-Project-Open-AAC/OS-DPI GitHub Wiki
An Action is an event that occurs when changes to the State match any programmed Conditions. An Action can be as simple as clicking on a button to clear the display window. Or, an Action can activate word prediction. Actions are determined by the UI designer to make the UI respond how ever they decide. A growing list of Actions can be assigned to buttons through declarative programming.

In the design pictured below there are two Actions defined.
-
If the Action originates in the grid, selecting an icon will add the label text to the display window. As seen in the grid screenshot, selecting the icon "I" has added "I" to the display window.
-
If the Action originates in the CLEAR button, selecting CLEAR will result in the display window contents being cleared.


-
Click on Add > Action
-
Fill in the Origin box. Origin refers to where the action originates in the design (e.g., layout, grid, homepage) and the Name that you have given that component.
Example: If you want the Action to originate in a grid that you have named "Core". Then in the box for Origin, you would type core.

-
Fill in the State box. State refers to shared variables (i.e., a variable that is shared among controls. State variables start with $ symbol (e.g., $Display). A single Action can have multiple States. To add more States, click Add > Update.
-
Fill in the New Value box. New Value refers to the updated Condition for the Action.
Example: If you want to design a grid-based UI where icons with text are treated as words and added to the display window when selected, then the **New Value **box would need to be filled with "add_word(#fill_display). This will tell the OS-DPI system to treat the data in your spreadsheet as a word. When the word is added to the display window a space will automatically be placed after the word. In this example, #fill_display is the name of a column in the spreadsheet that lists all of the words that could be added to the display window.
- If there is a Condition, fill that box in. Condition refers to the comparison between States and Fields that determines whether the Action gets triggered. If the Condition box is left blank, the Action will occur anytime the button is selected. A single Action can have multiple Conditions. To add more Conditions, click Add > Condition.
Example: If you want to design a UI where words in the display window are spoken when the Speak button is selected, then add you have to specify the Condition. For Condition insert #label='Speak'. The Condition here is that we only want this Action to occur when the Condition is met that the button #label = Speak.
Note: The rule is the first Action in the list always wins. In the screenshot below, the Action that uses #pronounce must be listed first, otherwise the first action of speaking the label (i.e., โitโ) will be triggered.

For more detail on creating Actions, check out this tutorial for creating a simple grid.
Origin | Condition | State | New Value |
---|---|---|---|
grid | #label = 'Speak' | $Speak | $Display |
space | $Display | add_letter('') | |
keyboard | $prefix | add_letter(#label) | |
$Display | add_letter(#label) | ||
predict | $prefix | $Display$prefix | replace_last(#label + ' ')'' |