Allow the defaultTextFormat initProps to be specified more conveniently.

git-svn-id: svn+ssh://src.earth.threerings.net/nenya/trunk@478 ed5b42cb-e716-0410-a449-f6a68f950b19
This commit is contained in:
Ray Greenwell
2008-04-30 20:15:28 +00:00
parent 9eb6476126
commit ad347a4c8d
+6 -3
View File
@@ -51,11 +51,11 @@ public class TextFieldUtil
* @param initProps contains properties with which to initialize the TextField. * @param initProps contains properties with which to initialize the TextField.
* Additionally it may contain the following properties: * Additionally it may contain the following properties:
* outlineColor: uint * outlineColor: uint
* * @param formatProps contains properties with which to initialize the defaultTextFormat.
* initProps may be destructively modified.
*/ */
public static function createField ( public static function createField (
text :String, initProps :Object = null, clazz :Class = null) :TextField text :String, initProps :Object = null, formatProps :Object = null, clazz :Class = null)
:TextField
{ {
var tf :TextField = (clazz == null) ? new TextField() : TextField(new clazz()); var tf :TextField = (clazz == null) ? new TextField() : TextField(new clazz());
@@ -64,6 +64,9 @@ public class TextFieldUtil
} }
Util.init(tf, initProps, null, MASK_FIELD_PROPS); Util.init(tf, initProps, null, MASK_FIELD_PROPS);
if (formatProps != null) {
tf.defaultTextFormat = createFormat(formatProps);
}
tf.text = text; tf.text = text;
if (tf.autoSize != TextFieldAutoSize.NONE) { if (tf.autoSize != TextFieldAutoSize.NONE) {
tf.width = tf.textWidth + WIDTH_PAD; tf.width = tf.textWidth + WIDTH_PAD;