Subjects of the considerations in chapters 16.6 to 16.11 are the component TextBox and its specializations MaskBox, ValueBox, HistoryBox, InputBox and ButtonBox.
The class TextBox (gb.qt4) implements a one-line text input component.
Figure 16.6.0.1.1: TextBoxes for entering ①, ② and displaying ③ strings
First, selected properties and methods of the TextBox class are described and then essential events are characterized. Finally, in → chapter 16.6.3 examples for the use of a TextBox in different applications are presented.
The class TextBox has these essential properties:
Property | Data type | Description |
---|---|---|
Alignment | Integer | Sets or returns the text alignment in the TextBox. You can use one of the following constants: Align.Normal, Align.Left, Align.Center or Align.Right. |
Font | Font | Sets the font or returns the font. |
Foreground | Integer | Sets the writing color or returns the color value. |
Length | Integer | Returns the text length of the text in the TextBox. |
MaxLength | Integer | Sets or returns the maximum text length in the TextBox. |
Password | Boolean | For the value True, asterisks are set instead of the individual characters. |
Pos | Integer | Sets the cursor position (number of characters from the beginning of the text) or returns the cursor position. |
ReadOnly | Boolean | Indicates with TRUE that the text cannot be changed (display mode). |
Selected | Boolean | Returns TRUE if text is selected in the TextBox. |
Selection | TextBox. Selection | Returns an object of type TextBox.Selection with which the selected text can be edited. |
Text | String | Sets the text in the TextBox or returns the text as a string. |
Table 16.6.0.2.1: Properties of the TextBox class
Only essential methods are presented for the TextBox class:
Method | Description |
---|---|
Clear() | Deletes all text in the TextBox. |
Insert(text* As String) | Inserts the specified text* at the current cursor position into the text. |
Select([ Start As Integer, Length As Integer]) | Defines the text to be marked. Start is the position of the first selected character in the text. Length is the length of the marker. If no argument is specified, the entire text is selected and highlighted. |
SelectAll() | Selects the entire text. |
Unselect() | Cancels the selection of selected text. |
Table 16.6.0.3.1: Methods of the TextBox class
These events are specific to a TextBox:
Event | Description |
---|---|
Activate () | The event is triggered when the Enter key is pressed while the TextBox has the focus. |
Change () | The event is triggered when the text in the TextBox changes. This happens when characters are entered using the keyboard or when the value of the TextBox.Text property changes. |
KeyPress () | Is triggered when a key is pressed while the TextBox is in focus. You receive information about the pressed key with the key class. |
Table 16.6.0.4.1: Selected events of the TextBox class
Gegenstand der Betrachtungen in den Kapiteln 16.6 bis 16.11 sind die Komponente TextBox und ihre Spezialisierungen MaskBox, ValueBox, HistoryBox, InputBox und ButtonBox.
Die Klasse TextBox (gb.qt4) implementiert eine einzeilige Texteingabe-Komponente.
Abbildung 16.6.0.1.1: TextBoxen zur Eingabe ①, ② und zur Anzeige ③ von Strings
Zuerst werden ausgewählte Eigenschaften und Methoden der Klasse TextBox beschrieben und dann wesentliche Ereignisse charakterisiert. Abschließend werden im → Kapitel 16.6.3 Beispiele für den Einsatz einer TextBox in unterschiedlichen Anwendungsfällen vorgestellt.
Die Klasse TextBox besitzt diese wesentlichen Eigenschaften:
Eigenschaft | Datentyp | Beschreibung |
---|---|---|
Alignment | Integer | Setzt die Text-Ausrichtung in der TextBox oder gibt diese Ausrichtung zurück. Sie können eine der folgenden Konstanten einsetzen: Align.Normal , Align.Left , Align.Center oder Align.Right. |
Font | Font | Setzt den Font oder gibt den Font zurück. |
Foreground | Integer | Setzt die Schreib-Farbe oder gibt den Farbwert zurück. |
Length | Integer | Gibt die Textlänge des Textes in der TextBox zurück. |
MaxLength | Integer | Setzt die maximale Textlänge in der TextBox oder gibt diesen Wert zurück. |
Password | Boolean | Für den Wert True werden Sternchen an Stelle der einzelnen Zeichen gesetzt. |
Pos | Integer | Setzt die Cursor-Position (Zeichenzahl vom Beginn des Textes) oder gibt die Cursor-Position zurück. |
ReadOnly | Boolean | Zeigt mit TRUE an, das der Text nicht geändert werden kann (Anzeige-Modus). |
Selected | Boolean | Gibt TRUE zurück, sofern Text in der TextBox markiert ist. |
Selection | TextBox.Selection | Gibt ein Objekt vom Typ TextBox.Selection zurück, mit dem der selektierte Text bearbeitet werden kann. |
Text | String | Setzt den Text in der TextBox oder gibt den Text als Zeichenkette zurück. |
Tabelle 16.6.0.2.1 : Eigenschaften der Klasse TextBox
Für die Klasse TextBox werden nur wesentliche Methoden vorgestellt:
Tabelle 16.6.0.3.1 : Methoden der Klasse TextBox
Diese Ereignisse sind spezifisch für eine TextBox:
Tabelle 16.6.0.4.1 : Ausgewählte Ereignisse der Klasse TextBox