Changing the value of a text dynamically
In this tutorial we’ll simulate a text that, when clicked, allows you to directly edit it, and replace the value of the original text with that entered by the user.
- Drag a Dynamic Panel. Right click on it and select ‘Edit contents’. Then, drag a label inside the panel.
- Select the dynamic panel and create a new panel.
- Insert a text input in the new panel. Drag also a button.
- Select the button you placed in the second panel and click Add Event (in the Event tab).
- Choose the ‘Set active panel’ option and select the first panel (it’s easier if you use the Outline tab). Click OK. The event that you just created is displayed in the Events tab.
- Click the gear next to the word “Do” in the Events tab. In the open context menu, click ‘Add Action’.
- Now choose Set Value, go to the first panel of the dynamic panel, and select the label.
- At the top of the dialog, where is says ‘Value is…’ select the option ‘Calculated’. Then select ‘Add expression’
- The expressions editor dialog will show up. In the Screen tab, select the second panel of the Dynamic Panel and drag the input text element to the top of the dialog (in the dotted circle).
- Click OK and return to the Event dialog box. Click OK again. You selected all the necessary commands so that when the user clicks the button, the text entered goes to the first panel.
- Select the label on the first panel, go to the Events tab and push the ‘Add event’ button. Select ‘set active panel’ and select the second panel. Push ok.
- Click the Simulate button to verify the results: the user can replace the original text by clicking on it.