API Docs for: 最后更新日期:2014年8月25日
Google搜索   
Show:

File: text/LTextField.js

/** @language japanese
 * 新しい LTextField インスタンスを作成します。LTextField インスタンスの作成後、親 LSprite オブジェクトの addChild() メソッドまたは addChildAt() メソッドを呼び出し、LTextField インスタンスを表示リストに追加します。
 * LTextField クラスのメソッドを使用すると、オーサリング時または実行時に作成したダイナミックテキストフィールドやテキスト入力フィールドにテキストを設定、選択、および操作できます。
 * @class LTextField
 * @extends LInteractiveObject
 * @constructor
 * @example
 * 	var theTextField = new LTextField();
 * 	theTextField.setType(LTextFieldType.INPUT);
 * 	theTextField.x = 10;
 * 	theTextField.y = 10;
 * 	addChild(theTextField);
 * @examplelink <p><a href="../../../api/LTextField/index.html" target="_blank">実際のサンプルを見る</a></p>
 * @since 1.0.0
 * @public
 */
var LTextField = (function () {
	function LTextField () {
		var s = this;
		LExtends(s, LInteractiveObject, []);
		/** @language japanese
		 * オブジェクトのタイプ
		 * @property type
		 * @type String
		 * @default LTextField
		 * @since 1.0.0
		 * @public
		 */
		s.type = "LTextField";
		s.texttype = null;
		/** @language japanese
		 * テキストフィールド内の現在のテキストであるストリングです。行は復帰文字('\n')で区切られます。
		 * @property text
		 * @type String
		 * @since 1.0.0
		 * @public
		 */
		s.text = "";
		/** @language japanese
		 * このテキストフォーマットでのテキストフォント名を示すストリングです。デフォルト値は null で、Flash Player ではテキストに Times New Roman フォントが使用されます。
		 * @property font
		 * @type String
		 * @since 1.0.0
		 * @default Arial
		 * @example
		 * 	var theTextField = new LTextField();
		 * 	theTextField.text = "font test";
		 * 	theTextField.x = 10;
		 * 	theTextField.y = 10;
		 * 	theTextField.font = "Georgia";
		 * 	addChild(theTextField);
		 * @examplelink <p><a href="../../../api/LTextField/font.html" target="_blank">実際のサンプルを見る</a></p>
		 * @public
		 */
		s.font = "Arial";
		/** @language japanese
		 * このテキストフォーマットのテキストのサイズ(ピクセル単位)です。
		 * @property size
		 * @type int
		 * @since 1.0.0
		 * @default 11
		 * @example
		 * 	var theTextField = new LTextField();
		 * 	theTextField.text = "size test";
		 * 	theTextField.x = 10;
		 * 	theTextField.y = 10;
		 * 	theTextField.size = 20;
		 * 	addChild(theTextField);
		 * @examplelink <p><a href="../../../api/LTextField/size.html" target="_blank">実際のサンプルを見る</a></p>
		 * @public
		 */
		s.size = "11";
		/** @language japanese
		 * テキストの色を示します。
		 * @property color
		 * @type String
		 * @since 1.0.0
		 * @default "#000000"
		 * @example
		 * 	var theTextField = new LTextField();
		 * 	theTextField.text = "color test";
		 * 	theTextField.x = 10;
		 * 	theTextField.y = 10;
		 * 	theTextField.color = "#FF0000";
		 * 	addChild(theTextField);
		 * @examplelink <p><a href="../../../api/LTextField/color.html" target="_blank">実際のサンプルを見る</a></p>
		 * @public
		 */
		s.color = "#000000";
		/** @language japanese
		 * テキストをボールドにするかどうかを指定します。
		 * @property weight
		 * @type String
		 * @since 1.0.0
		 * @default normal
		 * @example
		 * 	var theTextField = new LTextField();
		 * 	theTextField.text = "weight test";
		 * 	theTextField.x = 10;
		 * 	theTextField.y = 10;
		 * 	theTextField.weight = "bolder";
		 * 	addChild(theTextField);
		 * @examplelink <p><a href="../../../api/LTextField/weight.html" target="_blank">実際のサンプルを見る</a></p>
		 * @public
		 */
		s.weight = "normal";
		/** @language japanese
		 * 段落の行揃えの設定を示します(水平)。
		 * @property textAlign
		 * @type String
		 * @since 1.0.0
		 * @default left
		 * @public
		 */
		s.textAlign = "left";
		/** @language japanese
		 * 段落の行揃えの設定を示します(垂直)。
		 * @property textBaseline
		 * @type String
		 * @since 1.0.0
		 * @default top
		 * @public
		 */
		s.textBaseline = "top";
		s.heightMode = LTextField.HEIGHT_MODE_BOTTOM;
		/** @language japanese
		 * テキストエフェクト。
		 * @property stroke
		 * @type String
		 * @since 1.0.0
		 * @default false
		 * @example
		 * 	var theTextField = new LTextField();
		 * 	theTextField.text = "stroke test";
		 * 	theTextField.size = 50;
		 * 	theTextField.stroke = true;
		 * 	theTextField.lineWidth = 2;
		 * 	theTextField.lineColor = "#FF0000";
		 * 	addChild(theTextField);
		 * @examplelink <p><a href="../../../api/LTextField/stroke.html" target="_blank">実際のサンプルを見る</a></p>
		 * @public
		 */
		s.stroke = false;
		/** @language japanese
		 * テキストエフェクトの線のサイズ。
		 * @property lineWidth
		 * @type int
		 * @since 1.0.0
		 * @default 1
		 * @public
		 */
		s.lineWidth = 1;
		/** @language japanese
		 * テキストエフェクトの線の色。
		 * @property lineColor
		 * @type String
		 * @since 1.0.0
		 * @default "#000000"
		 * @public
		 */
		s.lineColor = "#000000";
		/** @language japanese
		 * 折り返す時、表示オブジェクトの幅を設定することができます。
		 * @property width
		 * @type int
		 * @since 1.0.0
		 * @default 150
		 * @public
		 */
		s.width = 150;
		s.height = s.size;
		/** @language japanese
		 * テキストフィールドがパスワードテキストフィールドであるかどうかを指定します。このプロパティの値が true である場合、テキストフィールドはパスワードテキストフィールドとして扱われ、入力された文字は実際の文字の代わりにアスタリスクで隠されます。false である場合、テキストフィールドはパスワードテキストフィールドとして扱われません。
		 * @property displayAsPassword
		 * @type Boolean
		 * @since 1.0.0
		 * @default false
		 * @example
		 * 	var theTextField = new LTextField();
		 * 	theTextField.setType(LTextFieldType.INPUT);
		 * 	theTextField.x = 10;
		 * 	theTextField.y = 10;
		 * 	theTextField.displayAsPassword = true;
		 * 	addChild(theTextField);
		 * @examplelink <p><a href="../../../api/LTextField/displayAsPassword.html" target="_blank">実際のサンプルを見る</a></p>
		 * @public
		 */
		s.displayAsPassword = false;
		s.wordWrap = false;
		s.multiline = false;
		/** @language japanese
		 * 複数行テキストフィールド内のテキスト行の数を定義します。setWordWrap(true)の場合、テキストが折り返されると行数は増えます。
		 * @property numLines
		 * @type int
		 * @since 1.9.0
		 * @public
		 */
		s.numLines = 1;
		/** @language japanese
		 * テキストを1文字ずつ画面に表示させるスピード。
		 * @property speed
		 * @type int
		 * @default 0
		 * @since 1.0.0
		 * @example
		 * 	LInit(50, "legend", 800, 480, main);
		 * 	function main () {
		 * 		var theTextField = new LTextField();
		 * 		theTextField.text = "wait click";
		 * 		theTextField.x = 10;
		 * 		theTextField.y = 10;
		 * 		theTextField.size = 20;
		 * 		addChild(theTextField);
		 * 		var button = new LButtonSample1("wind test start");
		 * 		button.textField = theTextField;
		 * 		button.x = 10;
		 * 		button.y = 100;
		 * 		addChild(button);
		 * 		button.addEventListener(LMouseEvent.MOUSE_DOWN, onclick);
		 * 	}
		 * 	function windOver(event){
		 * 		var theTextField = event.target;
		 * 		theTextField.removeEventListener(LTextEvent.WIND_COMPLETE, windOver);
		 * 		theTextField.text = "wind over";
		 * 	}
		 * 	function onclick(event){
		 * 	var theTextField = event.currentTarget.textField;
		 * 		if (theTextField.hasEventListener(LTextEvent.WIND_COMPLETE)) {
		 * 			theTextField.removeEventListener(LTextEvent.WIND_COMPLETE, windOver);
		 * 		}
		 * 		theTextField.text = "TEXTTEXTTEXTTEXTTEXTTEXTTEXTTEXTTEXTTEXT";
		 * 		theTextField.speed = 3;
		 * 		theTextField.wind();
		 * 		theTextField.addEventListener(LTextEvent.WIND_COMPLETE, windOver);
		 * 	}
		 * @examplelink <p><a href="../../../api/LTextField/wind.html" target="_blank">実際のサンプルを見る</a></p>
		 * @public
		 */
		s.speed = 0;
		s._speedIndex = 100;
	}
	LTextField.HEIGHT_MODE_BOTTOM = "bottom";
	LTextField.HEIGHT_MODE_BASELINE = "baseline";
	var p = {
		_showReady : function (c) {
			var s = this;
			c.font = s.weight + " " + s.size + "pt " + s.font;  
			c.textAlign = s.textAlign;
			c.textBaseline = s.textBaseline;
		},
		_ll_show : function (c) {
			var s = this, d, lbl, i, rc, j, l, k, m, b, enter;
			if (s.texttype == LTextFieldType.INPUT) {
				s.inputBackLayer.ll_show();
				rc = s.getRootCoordinate();
				if (LGlobal.inputBox.name == "input" + s.objectIndex) {
					LGlobal.inputBox.style.marginTop = (parseInt(LGlobal.canvasObj.style.marginTop) + (((rc.y + s.inputBackLayer.startY()) * parseInt(LGlobal.canvasObj.style.height) / LGlobal.canvasObj.height) >>> 0)) + "px";
					LGlobal.inputBox.style.marginLeft = (parseInt(LGlobal.canvasObj.style.marginLeft) + (((rc.x + s.inputBackLayer.startX()) * parseInt(LGlobal.canvasObj.style.width) / LGlobal.canvasObj.width) >>> 0)) + "px";
				}
				if (LGlobal.inputTextField && LGlobal.inputTextField.objectIndex == s.objectIndex) {
					return;
				}
			}
			lbl = s.text;
			if (s.displayAsPassword) {
				lbl = '';
				for (i=0, l = s.text.length; i < l; i++) {
					lbl += '*';
				}
			}
			c.fillStyle = s.color;
			if (s.stroke) {
				c.strokeStyle = s.lineColor;
				c.lineWidth = s.lineWidth + 1;  
			}
			if (s.wordWrap || s.multiline) {
				j = 0, k = 0, m = 0, b = 0;
				for (i = 0, l = s.text.length; i < l; i++) {
					enter = /(?:\r\n|\r|\n|¥n)/.exec(lbl.substr(i, 1));
					if (enter) {
						j = 0;
						k = i + 1;
						m++;
					}
					if (!enter) {
						if (s.stroke) {
							c.strokeText(lbl.substr(i, 1), j, m * s.wordHeight);
						}
						c.fillText(lbl.substr(i, 1), j, m * s.wordHeight);
					}
					s.numLines = m;
					j = c.measureText(s.text.substr(k, i + 1 - k)).width;
					if (s.wordWrap && j + c.measureText(lbl.substr(i, 1)).width > s.width) {
						j = 0;
						k = i + 1;
						m++;
					}
				}
				s.height = (m + 1) * s.wordHeight;
			} else {
				s.numLines = 1;
				if (s.stroke) {
					c.strokeText(lbl, 0, 0, c.measureText(lbl).width);
				}
				c.fillText(lbl, 0, 0, c.measureText(lbl).width);
			}
			if (s.windRunning) {
				s._ll_windRun();
			}
		},
		_wordHeight : function (h) {
			var s = this;
			if (h > 0) {
				s.wordHeight = h;
			} else {
				s.wordWrap = false;
				s.wordHeight = s.getHeight();
			}
			s.height = 0;
		},
		/** @language japanese
		 * フィールドが複数行テキストフィールドであるかどうかを示します。値が true である場合は複数行テキストフィールド、値が false である場合は単一行テキストフィールドです。LTextFieldType.INPUT タイプのフィールドでは、Enter キーで改行されるかどうかが決定されます(値が false の場合 Enter キーは無視されます)。
		 * @method setMultiline
		 * @param {Boolean} value フィールドが複数行テキストフィールドであるかどうかを示します。
		 * @param {int} height 一行のテキストフィールドの高さを設定する.
		 * @since 1.0.0
		 * @public
		 * @example
		 * 	var inputLayer = new LSprite();
		 * 	inputLayer.graphics.drawRect(1,"#000000",[0, 0, 400, 150]);
		 * 	var theTextField = new LTextField();
		 * 	theTextField.setType(LTextFieldType.INPUT,inputLayer);
		 * 	theTextField.setMultiline(true);
		 * 	addChild(theTextField);
		 * @examplelink <p><a href="../../../api/LTextField/setMultiline.html" target="_blank">実際のサンプルを見る</a></p>
		 */
		setMultiline : function (v, h) {
			var s = this;
			if (v) {
				s._wordHeight(h);
			}
			s.multiline = v;
		},
		/** @language japanese
		 * フテキストフィールドのテキストを折り返すかどうかを示す。値が true である場合は、テキストフィールドのテキストを折り返し、false である場合は折り返しません。デフォルト値は false です。
		 * @method setWordWrap
		 * @param {Boolean} value テキストフィールドのテキストを折り返すかどうかを示す。
		 * @param {int} height 一行のテキストフィールドの高さを設定する.
		 * @since 1.0.0
		 * @public
		 * @example
		 * 	var theTextField = new LTextField();
		 * 	theTextField.setWordWrap(true);
		 * 	theTextField.width = 200;
		 * 	theTextField.text = "text\ntext\ntexttexttexttexttexttexttexttexttexttexttexttexttexttext";
		 * 	addChild(theTextField);
		 * @examplelink <p><a href="../../../api/LTextField/setWordWrap.html" target="_blank">実際のサンプルを見る</a></p>
		 */
		setWordWrap : function (v, h) {
			var s = this;
			if (v) {
				s._wordHeight(h);
			}
			s.wordWrap = v;
		},
		/** @language japanese
		 * テキストフィールドのタイプです。次の LTextFieldType 定数のいずれかです。LTextFieldType.DYNAMIC はダイナミックテキストフィールドを指定します。このフィールドをユーザーが編集することはできません。LTextFieldType.INPUT はテキスト入力フィールドを指定します。このフィールドはユーザーが編集できます。デフォルト値: dynamic。
		 * @method setType
		 * @param {String} type テキストフィールドのタイプです。
		 * @param {LSprite} obj オブジェクトの形.
		 * @since 1.0.0
		 * @public
		 * @example
		 * 	var inputLayer = new LSprite();
		 * 	inputLayer.graphics.drawRect(1,"#000000",[0, 0, 400, 30]);
		 * 	var theTextField = new LTextField();
		 * 	theTextField.setType(LTextFieldType.INPUT,inputLayer);
		 * 	addChild(theTextField);
		 * @examplelink <p><a href="../../../api/LTextField/setType.html" target="_blank">実際のサンプルを見る</a></p>
		 */
		setType : function (type, inputBackLayer) {
			var s = this;
			if (s.texttype != type && type == LTextFieldType.INPUT) {
				if (inputBackLayer == null || inputBackLayer.type != "LSprite") {
					s.inputBackLayer = new LSprite();
					s.inputBackLayer.graphics.drawRect(1, "#000000", [0, -s.getHeight() * 0.4, s.width, s.getHeight() * 1.5]);
				} else {
					s.inputBackLayer = inputBackLayer;
				}
				s.inputBackLayer.parent = s;
				if (LMouseEventContainer.container[LMouseEvent.MOUSE_DOWN]) {
					LMouseEventContainer.pushInputBox(s);
				}
			} else {
				s.inputBackLayer = null;
				LMouseEventContainer.removeInputBox(s);
			}
			s.texttype = type;
		},
		ismouseon : function (e, cood) {
			var s = this;
			if (!e) {
				return false;
			}
			if (!s.visible) {
				return false;
			}
			if (!cood) {
				cood = {x : 0, y : 0, scaleX : 1, scaleY : 1};
			}
			if (s.mask) {
				if (!s.mask.parent) {
					s.mask.parent = s.parent;
				}
				if (!s.mask.ismouseon(e, cood)) {
					return false;
				}
			}
			if (s.inputBackLayer) {
				return s.inputBackLayer.ismouseon(e, {x : s.x * cood.scaleX + cood.x, y : s.y * cood.scaleY + cood.y, scaleX : cood.scaleX * s.scaleX, scaleY : cood.scaleY * s.scaleY});
			}
			return s.ismouseonShapes([{type : LShape.RECT, arg : [0, 0, s._getWidth(), s._getHeight()]}], e.offsetX, e.offsetY);
		},
		/** @language japanese
		 * 新しい LTextField オブジェクトとして、元のインスタンスのクローンを返します。オブジェクトはまったく同じコピーになります。
		 * @method clone
		 * @return {LTextField} 元のオブジェクトと同一の新しい LTextField オブジェクトです。
		 * @since 1.8.2
		 * @public
		 * @example
		 * 	var circle1 = new LSprite();
		 * 	circle1.graphics.drawRect(1,"#000000",[0,0,100,100],true,"#000000");
		 * 	var circle2 = circle1.clone();
		 * 	circle2.y = 120;
		 * 	addChild(circle1);
		 * 	addChild(circle2);
		 * @examplelink <p><a href="../../../api/LTextField/clone.html" target="_blank">実際のサンプルを見る</a></p>
		 */
		clone : function () {
			var s = this, a = new s.constructor();
			a.copyProperty(s);
			a.texttype = null;
			if (s.texttype ==  LTextFieldType.INPUT) {
				a.setType( LTextFieldType.INPUT);
			}
			return a;
		},
		mouseEvent : function (event, type, cood) {
			var s = this, on;
			if (s.inputBackLayer == null) {
				return;
			}
			on = s.ismouseon(event, cood);
			if (type != LMouseEvent.MOUSE_DOWN || !on) {
				return;
			}
			s.focus();
		},
		_ll_getValue : function () {
			if (LGlobal.inputBox.style.display != NONE) {
				LGlobal.inputTextField.text = LGlobal.inputTextBox.value;
				LEvent.removeEventListener(LGlobal.inputTextBox, LKeyboardEvent.KEY_DOWN, LGlobal.inputTextField._ll_input);
				LGlobal.inputBox.style.display = NONE;
				LGlobal.inputTextField.dispatchEvent(LFocusEvent.FOCUS_OUT);
				LGlobal.inputTextField = null;
			}
		},
		/** @language japanese
		 * LTextFieldオブジェクトは入力ボックスの場合、LTextFieldオブジェクトのtextを入力ボックスに反映する。
		 * @method updateInput
		 * @since 1.9.0
		 * @public
		 * @example
		 * 	var theTextField = new LTextField();
		 * 	theTextField.x = 20;
		 * 	theTextField.y = 20;
		 * 	theTextField.text = "Click Enter Key to clear the text!";
		 * 	addChild(theTextField);
		 * 	var theTextField1 = new LTextField();
		 * 	theTextField1.text = "test";
		 * 	theTextField1.x = 20;
		 * 	theTextField1.y = 100;
		 * 	theTextField1.setType(LTextFieldType.INPUT);
		 * 	addChild(theTextField1);
		 * 	theTextField1.addEventListener(LTextEvent.TEXT_INPUT, function (e) {
		 * 		if(e.keyCode == 13){
		 * 			e.currentTarget.text = "";
		 * 			e.currentTarget.updateInput();
		 * 			e.preventDefault();
		 * 		}
		 * 	});
		 * 	setTimeout(function () {
		 * 		theTextField1.focus();
		 * 	}, 200);
		 * @examplelink <p><a href="../../../api/LTextField/updateInput.html" target="_blank">実際のサンプルを見る</a></p>
		 */
		updateInput : function () {
			var s = this;
			if (s.texttype == LTextFieldType.INPUT && LGlobal.inputTextField.objectIndex == s.objectIndex) {
				LGlobal.inputTextBox.value = LGlobal.inputTextField.text;
			}
		},
		_ll_input : function (e) {
			var event = new LEvent(LTextEvent.TEXT_INPUT);
			event.keyCode = e.keyCode;
			LGlobal.inputTextField.text = LGlobal.inputTextBox.value;
			if (LGlobal.inputTextField.hasEventListener(LTextEvent.TEXT_INPUT)) {
				e.returnValue = LGlobal.inputTextField.dispatchEvent(event);
			} else {
				e.returnValue = true;
			}
		},
		/** @language japanese
		 * フォーカスを取得。
		 * @method focus
		 * @since 1.9.0
		 * @public
		 * @example
		 * 	var theTextField = new LTextField();
		 * 	theTextField.x = 20;
		 * 	theTextField.y = 20;
		 * 	theTextField.text = "Click the Enter Key, please!";
		 * 	addChild(theTextField);
		 * 	var theTextField1 = new LTextField();
		 * 	theTextField1.x = 20;
		 * 	theTextField1.y = 100;
		 * 	theTextField1.setType(LTextFieldType.INPUT);
		 * 	addChild(theTextField1);
		 * 	theTextField1.addEventListener(LTextEvent.TEXT_INPUT, function (e) {
		 * 		if(e.keyCode == 13){
		 * 			theTextField2.focus();
		 * 		}
		 * 	});
		 * 	var theTextField2 = new LTextField();
		 * 	theTextField2.x = 20;
		 * 	theTextField2.y = 140;
		 * 	theTextField2.setType(LTextFieldType.INPUT);
		 * 	addChild(theTextField2);
		 * 	theTextField2.addEventListener(LTextEvent.TEXT_INPUT, function (e) {
		 * 		if(e.keyCode == 13){
		 * 			theTextField1.focus();
		 * 		}
		 * 	});
		 * 	setTimeout(function () {
		 * 		theTextField1.focus();
		 * 	}, 200);
		 * @examplelink <p><a href="../../../api/LTextField/focus.html" target="_blank">実際のサンプルを見る</a></p>
		 */
		focus : function () {
			var s = this, sc, sx;
			if (!s.parent) {
				return;
			}
			if (s.texttype != LTextFieldType.INPUT) {
				return;
			}
			if (LGlobal.inputTextField && LGlobal.inputTextField.objectIndex != s.objectIndex) {
				s._ll_getValue();
			}
			s.dispatchEvent(LFocusEvent.FOCUS_IN);
			sc = s.getAbsoluteScale();
			LGlobal.inputBox.style.display = "";
			LGlobal.inputBox.name = "input" + s.objectIndex;
			LGlobal.inputTextField = s;
			LGlobal.inputTextareaBoxObj.style.display = NONE;
			LGlobal.inputTextBoxObj.style.display = NONE;
			LGlobal.passwordBoxObj.style.display = NONE;
			if (s.displayAsPassword) {
				LGlobal.inputTextBox = LGlobal.passwordBoxObj;
			} else if (s.multiline) {
				LGlobal.inputTextBox = LGlobal.inputTextareaBoxObj;
			} else {
				LGlobal.inputTextBox = LGlobal.inputTextBoxObj;
			}
			sx = parseInt(LGlobal.canvasObj.style.width) / LGlobal.canvasObj.width;
			sy = parseInt(LGlobal.canvasObj.style.height) / LGlobal.canvasObj.height;
			LGlobal.inputTextBox.style.display = "";
			LGlobal.inputTextBox.value = s.text;
			LGlobal.inputTextBox.style.height = s.inputBackLayer.getHeight() * sc.scaleY * s.scaleY * sy + "px";
			LGlobal.inputTextBox.style.width = s.inputBackLayer.getWidth() * sc.scaleX * s.scaleX * sx + "px";
			LGlobal.inputTextBox.style.color = s.color;
			LGlobal.inputTextBox.style.fontSize = ((s.size * parseFloat(LGlobal.canvasObj.style.height) / LGlobal.canvasObj.height) >> 0) + "px";
			LGlobal.inputTextBox.style.fontFamily = s.font;
			LEvent.addEventListener(LGlobal.inputTextBox, LKeyboardEvent.KEY_DOWN, LGlobal.inputTextField._ll_input);
			if (s.texttype == LTextFieldType.INPUT) {
				rc = s.getRootCoordinate();
				if (LGlobal.inputBox.name == "input" + s.objectIndex) {
					LGlobal.inputBox.style.marginTop = (parseInt(LGlobal.canvasObj.style.marginTop) + (((rc.y + s.inputBackLayer.startY()) * parseInt(LGlobal.canvasObj.style.height) / LGlobal.canvasObj.height) >>> 0)) + "px";
					LGlobal.inputBox.style.marginLeft = (parseInt(LGlobal.canvasObj.style.marginLeft) + (((rc.x + s.inputBackLayer.startX()) * parseInt(LGlobal.canvasObj.style.width) / LGlobal.canvasObj.width) >>> 0)) + "px";
				}
			}
			setTimeout(function () {
				LGlobal.inputTextBox.focus();
			}, 0);
		},
		_getWidth : function () {
			var s = this;
			if (s.wordWrap) {
				return s.width;
			}
			LGlobal.canvas.font = s.size + "pt " + s.font;
			return LGlobal.canvas.measureText(s.text).width;
		},
		/** @language japanese
		 * 表示オブジェクトの幅を取得します(ピクセル単位)。
		 * @method getWidth
		 * @return {float} オブジェクトの幅。
		 * @since 1.0.0
		 * @public
		 * @example
		 * 	var theTextField = new LTextField();
		 * 	theTextField.text = "getWidth test";
		 * 	addChild(theTextField);
		 * 	trace(theTextField.getWidth());
		 * @examplelink <p><a href="../../../api/LTextField/getWidth.html" target="_blank">実際のサンプルを見る</a></p>
		 */
		getWidth : function (maskSize) {
			var s = this, w, mx, mw;
			w = s._getWidth() * s.scaleX;
			if (maskSize && s.mask) {
				mx = s.mask._startX ? s.mask._startX() : s.mask.startX();
				if (mx > w) {
					return 0;
				}
				mw = s.mask.getWidth();
				if (mx + mw > w) {
					return w - mx;
				} else {
					return mw;
				}
			}
			return w;
		},
		_getHeight : function () {
			var s = this, c = LGlobal.canvas, i, l, j, k, m, enter;
			if (s.wordWrap) {
				c.font = s.weight + " " + s.size + "pt " + s.font;
				if (s.height == 0) {
					j = 0, k = 0, m = 0;
					for (i = 0, l = s.text.length; i < l; i++) {
						j = c.measureText(s.text.substr(k, i - k)).width;
						enter = /(?:\r\n|\r|\n|¥n)/.exec(s.text.substr(i, 1));
						if ((s.wordWrap && j > s.width) || enter) {
							j = 0;
							k = i;
							m++;
							if (enter) {
								k++;
							}
						}
					}
					s.height = (m + 1) * s.wordHeight;
				}
				return s.height;
			}
			c.font = s.weight + " " + s.size + "pt " + s.font; 
			l = c.measureText("O").width * 1.2;
			if (s.heightMode == LTextField.HEIGHT_MODE_BASELINE) {
				l = l * 1.2;
			}
			return l;
		},
		/** @language japanese
		 * 表示オブジェクトの高さを取得します(ピクセル単位)。
		 * @method getHeight
		 * @return {float} オブジェクトの高さ。
		 * @since 1.0.0
		 * @public
		 * @example
		 * 	var theTextField = new LTextField();
		 * 	theTextField.text = "getHeight test";
		 * 	addChild(theTextField);
		 * 	trace(theTextField.getHeight());
		 * @examplelink <p><a href="../../../api/LTextField/getHeight.html" target="_blank">実際のサンプルを見る</a></p>
		 */
		getHeight : function (maskSize) {
			var s = this, h, my, mh;
			h = s._getHeight() * s.scaleY;
			if (maskSize && s.mask) {
				my = s.mask._startY ? s.mask._startY() : s.mask.startY();
				if (my > h) {
					return 0;
				}
				mh = s.mask.getHeight();
				if (my + mh > h) {
					return h - my;
				} else {
					return mh;
				}
			}
			return h;
		},
		/** @language japanese
		 * テキストを1文字ずつ画面に表示させる。
		 * @method wind
		 * @since 1.3.0
		 * @public
		 * @example
		 * 	LInit(50, "legend", 800, 480, main);
		 * 	function main () {
		 * 		var theTextField = new LTextField();
		 * 		theTextField.text = "wait click";
		 * 		theTextField.x = 10;
		 * 		theTextField.y = 10;
		 * 		theTextField.size = 20;
		 * 		addChild(theTextField);
		 * 		var button = new LButtonSample1("wind test start");
		 * 		button.textField = theTextField;
		 * 		button.x = 10;
		 * 		button.y = 100;
		 * 		addChild(button);
		 * 		button.addEventListener(LMouseEvent.MOUSE_DOWN, onclick);
		 * 	}
		 * 	function windOver(event){
		 * 		var theTextField = event.target;
		 * 		theTextField.removeEventListener(LTextEvent.WIND_COMPLETE, windOver);
		 * 		theTextField.text = "wind over";
		 * 	}
		 * 	function onclick(event){
		 * 	var theTextField = event.currentTarget.textField;
		 * 		if (theTextField.hasEventListener(LTextEvent.WIND_COMPLETE)) {
		 * 			theTextField.removeEventListener(LTextEvent.WIND_COMPLETE, windOver);
		 * 		}
		 * 		theTextField.text = "TEXTTEXTTEXTTEXTTEXTTEXTTEXTTEXTTEXTTEXT";
		 * 		theTextField.speed = 3;
		 * 		theTextField.wind();
		 * 		theTextField.addEventListener(LTextEvent.WIND_COMPLETE, windOver);
		 * 	}
		 * @examplelink <p><a href="../../../api/LTextField/wind.html" target="_blank">実際のサンプルを見る</a></p>
		 */
		wind : function (listener) {
			var s = this;
			s.wind_over_function = listener;
			s.windRunning = true;
			s._ll_wind_text = s.text;
			s.text = "";
			s._ll_wind_length = 0;
		},
		_ll_windRun : function () {
			var s = this;
			if (s._speedIndex++ < s.speed) {
				return;
			}
			s._speedIndex = 0;
			if (s._ll_wind_length > s._ll_wind_text.length) {
				s.windRunning = false;
				if (s.wind_over_function) {
					s.wind_over_function();
				}
				s.dispatchEvent(new LEvent(LTextEvent.WIND_COMPLETE));
				return;
			}
			s.text = s._ll_wind_text.substring(0, s._ll_wind_length);
			s._ll_wind_length++;
		},
		/** @language japanese
		 * <p>使ったメモリをクリアする。</p>
		 * @method die
		 * @since 1.0.0
		 * @public
		 */
		die : function () {
			LMouseEventContainer.removeInputBox(this);
		}
	};
	for (var k in p) {
		LTextField.prototype[k] = p[k];
	}
	return LTextField;
})();
/** @language japanese
 * LTextFieldオブジェクトがフォーカスを取得した後に送出されます。
 * <p><a href="LFocusEvent.html#property_FOCUS_IN">LFocusEvent.FOCUS_IN</a></p>
 * @event LFocusEvent.FOCUS_IN
 */
/** @language japanese
 * LTextFieldオブジェクトがフォーカスを失った後に送出されます。
 * <p><a href="LFocusEvent.html#property_FOCUS_OUT">LFocusEvent.FOCUS_OUT</a></p>
 * @event LFocusEvent.FOCUS_OUT
 */
/** @language japanese
 * 利用不可。
 * @event LMouseEvent.MOUSE_DOWN
 */
/** @language japanese
 * 利用不可。
 * @event LMouseEvent.MOUSE_UP
 */
/** @language japanese
 * 利用不可。
 * @event LMouseEvent.MOUSE_MOVE
 */
/** @language japanese
 * 利用不可。
 * @event LMouseEvent.MOUSE_OUT
 */
/** @language japanese
 * 利用不可。
 * @event LMouseEvent.MOUSE_OVER
 */
/** @language japanese
 * 利用不可。
 * @event LMouseEvent.DOUBLE_CLICK
 */