[ Team LiB ] |
Recipe 8.17 Formatting User-Input Text8.17.1 ProblemYou want to apply formatting to text as it is entered into a text field by the user. 8.17.2 SolutionApply a TextFormat object using the setNewTextFormat( ) method of the text field. 8.17.3 DiscussionYou should use the setNewTextFormat( ) method of a text field object to apply text formatting to text as it is entered by the user. You should create a TextFormat object as in Recipe 8.16 and then pass that object to the text field's setNewTextFormat( ) method: myTextFormat = new TextFormat( ); myTextFormat.color = 0x0000FF; // Make the text blue. myTextField.setNewTextFormat(myTextFormat); When you use setNewTextFormat( ), the formatting is applied to text that the user types into the field. 8.17.4 See Also |
[ Team LiB ] |