Text field

from Wikipedia, the free encyclopedia
Keyboard entry into a text field (animation)

A text field or a text box , or, for the sake of simplicity, an input field , is a control element of a graphical user interface that can receive and display keyboard inputs or program outputs in the form of a character string . It is used for input in the sense of a computer program .

Simple dialog window with labeling field, text field (value highlighted ) and two buttons. When you press “OK”, the actual input takes place in the sense of a computer program .

Text fields are mainly used in dialog windows , web forms , and in application programs for interaction with the user .

The basic implementation in HTML is input. But this method also controls other fields such as buttons (buttons), checkboxes (check box), and radio buttons (radio buttons). Together, these types form the elementary input elements in HTML, as they have been widely used since the 1990s. Its development dates back to the early 1980s when the first operating systems and applications with a graphical user interface were established.

Automatic text completion while typing ( autocomplete ) for text fields is widespread today . Also AutoCorrect mechanisms are possible.

Special uses and variants

  • In the context of electronic search queries, i.e. orders directed to electronic data processing systems , databases or search engines to search through the respective database for specific search terms or search masks , one also speaks of a search field . This can be part of a search bar.
  • In the case of a password field , the typed character string is deliberately not shown; in most cases, each typed character is replaced by an asterisk (*) .
  • A date field always works (internally) with a character string in a certain format that represents a point in time . Ideally, the user is allowed to select this point in time in a calendar view instead of typing it in.
  • A number field only accepts numerical values ​​( digits and, if necessary, decimal separators ).
  • Most programming languages and development environments distinguish between single and multi-line text fields. For multi-line text fields, special controls are sometimes available, for example called text area (for example in HTML or Java ) or memo field (for example in Microsoft Office or Delphi ).
  • With text editors a text field for an edit box is possible; it is an alternative to editing directly in the displayed text. For example, Wikipedia uses a system with separate preview and editing fields (editor of the basic software). Since the Wikimedia software is text-based, the edit field is a pure text field for the source code ; the modern visual editor , on the other hand, is a WYSIWYG editor with direct input into the display.

A more recent form of input field is the related combo box, in which a text field is combined with other input methods, such as a selection list of preset or previously entered character strings.

Examples

C #

The following example in the C # programming language shows the implementation of a text field and a button with a combo box. The event handler of the button places a text in the text box (see event ).

using System.Windows.Forms;

public class MainForm : System.Windows.Forms.Form
{
	private TextBox exampleTextBox;
	private Button exampleButton;
	
	// Konstruktor des MainForms.
	public MainForm()
	{
		InitializeTextBoxAndButton();
	}
	
	// Startet die Anwendung und erzeugt das MainForm durch Aufruf des Konstruktors.
    public static void Main()
    {
        Application.Run(new MainForm());
    }
	
	// Initialisiert das Textfeld und den Button.
	private void InitializeTextBoxAndButton()
	{
		exampleTextBox = new System.Windows.Forms.TextBox();
		exampleTextBox.Location = new System.Drawing.Point(50, 25);
		exampleTextBox.Size = new System.Drawing.Size(200, 100);
		exampleTextBox.AcceptsReturn = true;
		exampleTextBox.AcceptsTab = true;
		exampleTextBox.Multiline = true; // Legt fest, dass das Textfeld mehrere Zeilen haben kann und Zeilenumbrüche ermöglicht.
		exampleTextBox.ScrollBars = System.Windows.Forms.ScrollBars.Vertical;
		Controls.Add(exampleTextBox);
		
		exampleButton = new System.Windows.Forms.Button();
		exampleButton.Location = new System.Drawing.Point(50, 150);
		exampleButton.Size = new System.Drawing.Size(200, 25);
		exampleButton.Text = "Text in der Textbox ausgeben";
		Controls.Add(exampleButton);
		
		// Verknüpft die Ereignisbehandlungsmethode mit dem Klickereignis Click des Buttons.
		exampleButton.Click += exampleButton_Clicked;
	}
	
	// Diese Methode wird aufgerufen, wenn der Benutzer den Button klickt.
	private void exampleButton_Clicked(object sender, System.EventArgs e)
	{
		exampleTextBox.Text = "Hallo Leser!\r\nDer Button wurde geklickt."; // Setzt den 2-zeiligen Text in die Textbox.
	}
}

Web links

  • Input field . In: Duden online dictionary . Bibliographical Institute GmbH

Individual evidence

  1. input. In: selfhtml (updated wiki article).
  2. See help: edit page , Wikipedia help page .
  3. Microsoft Docs: TextBox Class