TextBoxes, TextAreas and Fields

OBJECTS

  typedef control  field;
  typedef control  textbox;

FUNCTIONS

  field    newfield(char *text, rect r);	/* one-line textbox */
  field    newpassword(char *text, rect r);	/* one-line password field */
  textbox  newtextbox(char *text, rect r);	/* words wrap */
  textbox  newtextarea(char *text, rect r);	/* no word wrap */

  void     settext(textbox t, char *newtext);	/* change contents */
  char *   gettext(textbox t);			/* find contents */

NOTES

The newfield function creates an editable text field, with the specified text string displayed within it. The text field will be displayed on one line only and will scroll horizontally if the user enters more text into it than will fit within the rectangle.

The newpassword function creates a field in which user-typed text appears as a series of asterisks, thereby preventing other users from reading what is typed. The gettext and settext functions access the actual text that was typed, however.

To create a text-field which can contain multiple lines of text use the newtextbox function. A textbox has a vertical scrollbar which allows the user to move the text up and down. If a word will not fit on one line of text, that word will 'wrap' onto the next line of text.

The newtextarea function creates a slightly different kind of textbox. Instead of words 'wrapping' onto the next line if they cannot fit, a textarea has a horizontal scrollbar so the user can scroll to see the end of the line of text.

The text inside a textbox or a field can be changed using the settext function. This function makes a copy of the string and stores it into the textbox or field.

Use gettext to find the current text inside a textbox or field. The string returned from gettext is a read-only string! Do not modify it or free it, or your program may crash unexpectedly.