Creating Graphical User Interfaces    

Edit Text

Edit text controls are fields that enable users to enter or modify text strings. Use edit text when you want text as input. The String property contains the text entered by the user.

To obtain the string typed by the user, get the String property in the callback.

Single or Multiple Line Selection

The values of the Min and Max properties determine whether users can select single or multiple lines in the edit text:

For example, setting Max to 2, with the default value of 0 for Min, enables users to select multiple lines

Obtaining Numeric Data from an Edit Test Component

MATLAB returns the value of the edit text String property as a character string. If you want users to enter numeric values, you must convert the characters to numbers. You can do this using the str2double command, which converts strings to doubles. If the user enters nonnumeric characters, str2double returns NaN.

You can use the following code in the edit text callback. It gets the value of the String property and converts it to a double. It then checks whether the converted value is NaN (isnan), indicating the user entered a nonnumeric character and displays an error dialog (errordlg).

Triggering Callback Execution

On UNIX systems, clicking on the menu bar of the figure window causes the edit text callback to execute. However, on Microsoft Windows systems, if an editable text box has focus, clicking on the menu bar does not cause the editable text callback routine to execute. This behavior is consistent with the respective platform conventions. Clicking on other components or the background of the GUI executes the callback.


  Check Boxes Static Text