Posted by
Jakub Pawlak in
Classes & Controls
Sep 20th, 2009 |
no responses
TextField control is a standard editable text field that you are using in fast every available application (browsers, preference panels, IM’s, e-mail clients etc.). It can contain only one line of text, with one font, font size and style. Learn how can you use it!
Adding text to a TextField
For example add to the Window PushButton Control and double click on it (at a glance PushButton Sub Action()). Then enter there the code below:
1
| TextField.Text = "REALbasic City sample text" |
Reading text from a TextField
Reading the content from TextField is extreme easy like this s = TextField1.Text. Here you got a example that shows Message Box:
1
2
3
4
5
6
7
| Dim s As String
Dim d as New MessageDialog //declare the MessageDialog object
Dim b as MessageDialogButton //handling the result
s = TextField1.Text
d.Message=s
b=d.ShowModal |
Using Mask
Simply select TextField in GUI builder Tab and then in Property and Value find Behavior -> Mask and place there ex. ###-##-####. You can also add a code in TextField Sub Open(). Go to Window1 code editor Controls -> TextField -> Open.
1
2
| TextField.Mask = "###-##-####" //US Social Security number
TextField.Mask = "(###) ###-####" //US Phone number, with area code |
Mask Character in TextField
# – The single digit placeholder. Entry optional. If this position is left blank in the mask, it will be rendered as a space. Plus and minus signs are allowed. The user can type only a digit character in this position.
. – Decimal placeholder. The decimal placeholder that is actually used is specified in the user’s International settings. The character is treated as a literal (formatting) character for masking purposes.
, – Thousands separator. The thousands separator that is actually used is specified in the user’s International settings. The character is treated as a literal (formatting) character for masking purposes.
: – Time separator. The time separator that is actually used is specified in the user’s International settings. The character is treated as a literal (formatting) character for masking purposes.
/ – Date separator. The date separator that is actually used is specified in the user’s International settings. The character is treated as a literal (formatting) character for masking purposes.
\ – Mask escape character. Treat the next character in the mask as a literal. The escape character enables you to use the ‘#’, ‘&’, ‘A’, ‘?’ (and so on) characters in the mask. The escapted character is treated as a literal (formatting) character.
& Character or space placeholder. Valid values are the ASCII characters 32-126 and the non-ASCII characters 128-255.
C – Character or space placeholder, where entry is optional. It operates like the ‘&’ placeholder.
> – Convert all the characters that follow to uppercase. Uppercasing works beyond the ASCII range where appropriate, e.g., ü becomes Ü.
< – Convert all the characters that follow to lowercase. Lowercasing works beyond the ASCII range where appropriate, e.g., Ü becomes ü.
A – Alphanumeric character placeholder, where entry is mandatory.
For example, the spec “AAA” specifies three alphanumeric characters.
a -Alphanumeric character placeholder, where entry is optional.
0 – Any single digit between 0 and 9. Entry is required.
9 – Digit or space where entry is optional.
? – Alphabetic placeholder. Entry is optional.
L – Alphabetic placeholder. Entry is required. Any literal. All other symbols are displayed as literals for formatting purposes.
~ – Reserved for future use. If you use “~” it will trigger an exception error. Use \~ instead.
Using TextField Property and Value
When you select TextField in GUI builder you can change some Property and Value for this control. We have got there position properties (width, height), appearance (text color, border), font (text size, text font), initial state (default text), behaviors (mask, read only) or database binding. Please play with them for a wile to understand what is happening when you change the values.