Recipe 8.3 Creating an Outline Around a Text Field

8.3.1 Problem

You want to make a border around a text field.

8.3.2 Solution

Set the text field's border property to true. Additionally, you can change the color of the border by setting the object's borderColor property.

8.3.3 Discussion

By default, a text field lacks a visible border, which may be desirable. For example, you may not want a border around an item label. However, user input fields have borders by convention. The border shows the user where to click to input a value. Simply setting a text field's border property to true turns on the border around the object.

myTextField.border = true;

To turn off the border, simply set the border property to false.

The default border color is black but can be changed by setting the borderColor property, which accepts a hex RGB value corresponding to the desired color:

myTextField.borderColor = 0xFF00FF;  // Make the border violet.

8.3.4 See Also

Recipe 3.2 and Recipe 8.4

    Part I: Local Recipes
    Part II: Remote Recipes