MCPcopy Index your code
hub / github.com/jabbany/CommentCoreLibrary / TextField

Class TextField

src/scripting/api/Display/TextField.ts:56–184  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

54 * @author Jim Chen
55 */
56 export class TextField extends DisplayObject {
57 private _text:string;
58 private _textFormat:TextFormat;
59 private _background:boolean = false;
60 private _backgroundColor:number = 0xffffff;
61 private _border:boolean = false;
62 private _borderColor:number = 0;
63
64 constructor(text:string = "", color:number = 0) {
65 super();
66 this._text = text;
67 this._textFormat = new TextFormat();
68 this._textFormat.color = color;
69 this.boundingBox.width = this.textWidth;
70 this.boundingBox.height = this.textHeight;
71 }
72
73 get text():string {
74 return this._text;
75 }
76
77 set text(t:string) {
78 this._text = t;
79 this.boundingBox.width = this.textWidth;
80 this.boundingBox.height = this.textHeight;
81 this.propertyUpdate("text", this._text);
82 }
83
84 get length():number {
85 return this.text.length;
86 }
87
88 set length(l:number) {
89 __trace("TextField.length is read-only.", "warn");
90 }
91
92 get htmlText():string {
93 return this.text;
94 }
95
96 set htmlText(text:string) {
97 __trace("TextField.htmlText is restricted due to security policy.", "warn");
98 this.text = text.replace(/<\/?[^>]+(>|$)/g, '');
99 }
100
101 set textWidth(w:number) {
102 __trace("TextField.textWidth is read-only", "warn");
103 }
104
105 set textHeight(h:number) {
106 __trace("TextField.textHeight is read-only", "warn");
107 }
108
109 get textWidth():number {
110 /** TODO: Fix this to actually calculate the width **/
111 return this._text.length * this._textFormat.size;
112 }
113

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected