TextFieldUtil

Kind of class:public class
Package:org.casalib.util
Inherits from:none
Version:09/06/09
Author:Aaron Clinger, Mike Creighton
Classpath:org.casalib.util.TextFieldUtil
File last modified:Sunday, 06 September 2009, 08:19:40
Utilities for working with TextFields.

Summary


Class methods
  • hasOverFlow (field:TextField) : Boolean
    • Determines if textfield has more text than can be displayed at once.
  • formatSmallCaps (field:TextField, largeFormat:TextFormat) : void
    • Applies the supplied TextFormat to all upper case letters then upper cases all lower case characters.
  • classSmallCaps (field:TextField, largeClass:String) : void
    • Adds the supplied CSS class to all upper case letters then upper cases all lower case characters.
  • removeOverFlow (field:TextField, omissionIndicator:String = "") : String
    • Removes text overflow on a textfield with the option of an ommission indicator.

Class methods

classSmallCaps

public static function classSmallCaps (
field:TextField, largeClass:String) : void

Adds the supplied CSS class to all upper case letters then upper cases all lower case characters. The function works by wrapping each upper case letter in a span tag with the defined class name applied.
Parameters:
field :
TextField to convert to small caps.
largeClass:
The CSS class name you wish to apply to the upper case letters.
Example:
  • var smallCapsStyle:StyleSheet = new StyleSheet();
    smallCapsStyle.parseCSS("p {font-size:15px;} .smallCaps {font-size:30px;}");
    
    var title:TextField = new TextField();
    title.autoSize      = TextFieldAutoSize.LEFT;
    title.styleSheet    = smallCapsStyle;
    title.htmlText      = "<p>This Text is Small Caps.</p>";
    
    TextFieldUtil.classSmallCaps(title, "smallCaps");
    
    this.addChild(title);
See also:

formatSmallCaps

public static function formatSmallCaps (
field:TextField, largeFormat:TextFormat) : void

Applies the supplied TextFormat to all upper case letters then upper cases all lower case characters.
Parameters:
field :
TextField to convert to small caps.
largeFormat:
The format you wish to apply to the upper case letters (usually a larger text size).
Example:
  • var small:TextFormat = new TextFormat();
    var large:TextFormat = new TextFormat();
    
    small.size = 15;
    large.size = 30;
    
    var title:TextField = new TextField();
    title.autoSize      = TextFieldAutoSize.LEFT;
    title.text          = "This Text is Small Caps.";
    title.setTextFormat(small);
    
    TextFieldUtil.formatSmallCaps(title, large);
    
    this.addChild(title);
See also:

hasOverFlow

public static function hasOverFlow (
field:TextField) : Boolean

Determines if textfield has more text than can be displayed at once.
Parameters:
field:
Textfield to check for text overflow.
Returns:
  • Returns true if textfield has text overflow; otherwise false.

removeOverFlow

public static function removeOverFlow (
field:TextField, omissionIndicator:String = "") : String

Removes text overflow on a textfield with the option of an ommission indicator.
Parameters:
field :
Textfield to remove overflow.
omissionIndicator:
Text indication that an omission has occured, normally "..."; defaults to no indication.
Returns:
  • Returns the omitted text; if there was no text ommitted function returns a empty String ("").
Usage note:
  • The TextField cannot contain HTML text.