Get and Set Text FieldsAuthor: Carl Sassenrath Here is an example of how to get a string that a user typed into a text field:
Type something into the field and click the button to see it on the console. Here's how it works: when the layout is made, the field face is assigned to the f1 variable. After that, you can get or set the contents of the field by using f1/text. Here is an example of how to set a text field:
When you click the button, the field will get the current date as a string. Note the call to SHOW in order to display the change. This is required. Here is another example:
Now type something in the first field and press enter to see it appear in the second field. Of course, this works for more than just text fields. This example changes a text line:
The text you type into the field will show up in the text string below it (after you hit enter). Note that the text face is given a width of 300 (because no text was provided to it in the layout). If you forget to do that, you won't see the text correctly. |