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
Articles