Packagecom.threerings.text
Classpublic class TextFieldUtil



Protected Properties
 PropertyDefined by
  _lastSelected : TextField
[static] The last tracked TextField to be selected.
TextFieldUtil
  _mouseables : Dictionary
[static]
TextFieldUtil
Public Methods
 MethodDefined by
  
createField(text:String, initProps:Object = null, formatProps:Object = null, clazz:Class = null):TextField
[static] Create a TextField.
TextFieldUtil
  
createFormat(initProps:Object):TextFormat
[static] Create a TextFormat using initProps.
TextFieldUtil
  
setFocusable(field:TextField):void
[static] Add a special MouseEvent.CLICK listener so that the specified field is focusable even inside a security boundary.
TextFieldUtil
  
setMaximumTextWidth(tf:TextField, width:Number, truncationString:String = "..."):Boolean
[static] Ensures that a single-line TextField is not wider than the specified width, and truncates it with the truncation string if is.
TextFieldUtil
  
trackOnlyLinksMouseable(textField:TextField, on:Boolean = true):void
[static] Install listeners on the specified TextField such that the mouseEnabled property is only true when the mouse is over a link.
TextFieldUtil
  
trackSingleSelectable(textField:TextField):void
[static] Include the specified TextField in a set of TextFields in which only one may have a selection at a time.
TextFieldUtil
  
updateFormat(field:TextField, props:Object):void
[static] Update the defaultTextFormat for the specified field, as well as all text therein.
TextFieldUtil
  
updateText(field:TextField, text:String):void
[static] Update the text in the field, automatically resizing it if appropriate.
TextFieldUtil
Protected Methods
 MethodDefined by
  
handleFieldFocus(event:MouseEvent):void
[static] Handle focusing the text field.
TextFieldUtil
  
handleLastSelectedRemoved(... ignored):void
[static] Internal method related to tracking a single selectable TextField.
TextFieldUtil
  
handleTrackedSelection(event:MouseEvent):void
[static] Internal method related to tracking a single selectable TextField.
TextFieldUtil
  
handleTrackMouseable(event:Event):void
[static] Checks every damn frame to see if we should make a TextField mouse-enabled.
TextFieldUtil
  
updateSelection(field:TextField):void
[static] Process the selection.
TextFieldUtil
Public Constants
 ConstantDefined by
  HEIGHT_PAD : int = 4
[static] A fudge factor that must be added to a TextField's textHeight when setting the height.
TextFieldUtil
  WIDTH_PAD : int = 5
[static] A fudge factor that must be added to a TextField's textWidth when setting the width.
TextFieldUtil
Protected Constants
 ConstantDefined by
  DEFAULT_FORMAT_PROPS : Object
[static]
TextFieldUtil
  _frameDispatcher : Sprite
[static]
TextFieldUtil
  MASK_FIELD_PROPS : Object
[static]
TextFieldUtil
Property detail
_lastSelectedproperty
protected static var _lastSelected:TextField

The last tracked TextField to be selected.

_mouseablesproperty 
protected static var _mouseables:Dictionary
Method detail
createField()method
public static function createField(text:String, initProps:Object = null, formatProps:Object = null, clazz:Class = null):TextField

Create a TextField. The field will have setFocusable() called on it. Note that if the autoSize property is not none, then the field will be resized to the size of the text, overwriting any width/height properties specified.

Parameters
text:String — contains properties with which to initialize the TextField.
Additionally it may contain the following properties:
outlineColor: uint,
outlineWidth: Number (default 2),
outlineStrength: Number (default 255)
 
initProps:Object (default = null) — contains properties with which to initialize the defaultTextFormat.
 
formatProps:Object (default = null)
 
clazz:Class (default = null)

Returns
TextField
createFormat()method 
public static function createFormat(initProps:Object):TextFormat

Create a TextFormat using initProps. If unspecified, the following properties have default values: size: 18 font: _sans

Parameters
initProps:Object

Returns
TextFormat
handleFieldFocus()method 
protected static function handleFieldFocus(event:MouseEvent):void

Handle focusing the text field.

Parameters
event:MouseEvent
handleLastSelectedRemoved()method 
protected static function handleLastSelectedRemoved(... ignored):void

Internal method related to tracking a single selectable TextField.

Parameters
... ignored
handleTrackedSelection()method 
protected static function handleTrackedSelection(event:MouseEvent):void

Internal method related to tracking a single selectable TextField.

Parameters
event:MouseEvent
handleTrackMouseable()method 
protected static function handleTrackMouseable(event:Event):void

Checks every damn frame to see if we should make a TextField mouse-enabled.

Parameters
event:Event
setFocusable()method 
public static function setFocusable(field:TextField):void

Add a special MouseEvent.CLICK listener so that the specified field is focusable even inside a security boundary.

Parameters
field:TextField
setMaximumTextWidth()method 
public static function setMaximumTextWidth(tf:TextField, width:Number, truncationString:String = "..."):Boolean

Ensures that a single-line TextField is not wider than the specified width, and truncates it with the truncation string if is. If the TextField is truncated, it will be resized to its new textWidth.

Parameters
tf:TextField — the maximum pixel width of the TextField. If tf.width > width, the text inside the TextField will be truncated, and will have the truncation string appended.
 
width:Number — the string to append to the end of the TextField if it exceeds the specified width.
 
truncationString:String (default = "...")

Returns
Boolean — true if truncation took place
trackOnlyLinksMouseable()method 
public static function trackOnlyLinksMouseable(textField:TextField, on:Boolean = true):void

Install listeners on the specified TextField such that the mouseEnabled property is only true when the mouse is over a link.

Parameters
textField:TextField
 
on:Boolean (default = true)
trackSingleSelectable()method 
public static function trackSingleSelectable(textField:TextField):void

Include the specified TextField in a set of TextFields in which only one may have a selection at a time.

Parameters
textField:TextField
updateFormat()method 
public static function updateFormat(field:TextField, props:Object):void

Update the defaultTextFormat for the specified field, as well as all text therein.

Parameters
field:TextField
 
props:Object
updateSelection()method 
protected static function updateSelection(field:TextField):void

Process the selection.

Parameters
field:TextField
updateText()method 
public static function updateText(field:TextField, text:String):void

Update the text in the field, automatically resizing it if appropriate.

Parameters
field:TextField
 
text:String
Constant detail
DEFAULT_FORMAT_PROPSconstant
protected static const DEFAULT_FORMAT_PROPS:Object
_frameDispatcherconstant 
protected static const _frameDispatcher:Sprite
HEIGHT_PADconstant 
public static const HEIGHT_PAD:int = 4

A fudge factor that must be added to a TextField's textHeight when setting the height.

MASK_FIELD_PROPSconstant 
protected static const MASK_FIELD_PROPS:Object
WIDTH_PADconstant 
public static const WIDTH_PAD:int = 5

A fudge factor that must be added to a TextField's textWidth when setting the width.