Example 3: Operate on Element in Runtime
Run This Example in New Window
ForeUI provides a set of actions that belongs to the "Operate on Element..." category. Different elements may support various actions. We can operate on the element via these actions during the simulation.
Now let's make an interesting example: when we click the button, move the button upper.
Add a button element into the plot, then follow these steps:
1. Open behavior editor for the button and add the "Element Clicked" event.
2. Click the "Add Action" button and choose "Operate on Element".
3. The action chooser will pop up, choose the button element and then select the "Change Location" action. We can input the parameters for this action. In our case, the x position should not be changed, we set the y position to "currentY - 30", so that the button will move upper every time we click it.
The final event handler should looks like this:
Now let's run it, it works as we expected! Each time we click the button, it move up a little. You can view this online example to see the result.