Difference between revisions of "Documentation/DevGuide/Basic/Text Field"
OOoWikiBot (Talk | contribs) m (Robot: Changing Category:Documentation/Developers Guide/Basic and Dialogs) |
OOoWikiBot (Talk | contribs) m (FINAL VERSION FOR L10N) |
||
Line 6: | Line 6: | ||
|NextPage=Documentation/DevGuide/Basic/List Box | |NextPage=Documentation/DevGuide/Basic/List Box | ||
}} | }} | ||
− | {{DISPLAYTITLE:Text Field}} | + | {{Documentation/DevGuideLanguages|Documentation/DevGuide/Basic/{{SUBPAGENAME}}}} |
+ | {{DISPLAYTITLE:Text Field}} | ||
The text field control <idl>com.sun.star.awt.UnoControlEdit</idl> is used to get input from the user at runtime. In general, the text field is used for editable text, but it can also be made read-only by setting the <code>ReadOnly</code> property to <code>True</code>. The actual text displayed in a text field is controlled by the <code>Text</code> property. The maximum number of characters that can be entered by the user is specified with the <code>MaxTextLen</code> property. A value of 0 means that there is no limitation. By default, a text field displays a single line of text. This behavior is changed by setting the property <code>MultiLine</code> to <code>True</code>. The properties <code>HScroll</code> and <code>VScroll</code> displays a horizontal and vertical scroll bar. | The text field control <idl>com.sun.star.awt.UnoControlEdit</idl> is used to get input from the user at runtime. In general, the text field is used for editable text, but it can also be made read-only by setting the <code>ReadOnly</code> property to <code>True</code>. The actual text displayed in a text field is controlled by the <code>Text</code> property. The maximum number of characters that can be entered by the user is specified with the <code>MaxTextLen</code> property. A value of 0 means that there is no limitation. By default, a text field displays a single line of text. This behavior is changed by setting the property <code>MultiLine</code> to <code>True</code>. The properties <code>HScroll</code> and <code>VScroll</code> displays a horizontal and vertical scroll bar. | ||
Revision as of 12:36, 15 May 2009
The text field control com.sun.star.awt.UnoControlEdit is used to get input from the user at runtime. In general, the text field is used for editable text, but it can also be made read-only by setting the ReadOnly
property to True
. The actual text displayed in a text field is controlled by the Text
property. The maximum number of characters that can be entered by the user is specified with the MaxTextLen
property. A value of 0 means that there is no limitation. By default, a text field displays a single line of text. This behavior is changed by setting the property MultiLine
to True
. The properties HScroll
and VScroll
displays a horizontal and vertical scroll bar.
When a text field receives the focus by pressing the TAB key the displayed text is selected and highlighted by default. The default cursor position within the text field is to the right of the existing text. If the user starts typing while a block of text is selected, the selected text is replaced. In some cases, the user may change the default selection behavior and set the selection manually. This is done using the com.sun.star.awt.XTextComponent interface:
Dim sText As String Dim oSelection As New com.sun.star.awt.Selection REM get control oTextField = oDialog.getControl("TextField1") REM set displayed text sText = "Displayed Text" oTextField.setText( sText ) REM set selection oSelection.Min = 0 oSelection.Max = Len( sText ) oTextField.setSelection( oSelection )
The text field control is also used for entering passwords. The property EchoChar
specifies the character that is displayed in the text field while the user enters the password. In this context, the MaxTextLen
property is used to limit the number of characters that are typed in:
oTextFieldModel = oDialog.Model.TextField1 oTextFieldModel.EchoChar = Asc("*") oTextFieldModel.MaxTextLen = 8
A user can enter any kind of data into a text field, such as numerical values and dates. These values are always stored as a string in the Text property, thus leading to problems when evaluating the user input. Therefore, consider using a date field, time field, numeric field, currency field or formatted field instead.
Content on this page is licensed under the Public Documentation License (PDL). |