浏览代码

fixed calcMaxWidth with inputWidth defined

ncannasse 8 年之前
父节点
当前提交
e22e314ab6
共有 1 个文件被更改,包括 4 次插入1 次删除
  1. 4 1
      h2d/TextInput.hx

+ 4 - 1
h2d/TextInput.hx

@@ -257,7 +257,10 @@ class TextInput extends Text {
 
 	override function initGlyphs(text:hxd.UString, rebuild = true, handleAlign = true, lines:Array<Int> = null):Void {
 		super.initGlyphs(text, rebuild, handleAlign, lines);
-		if( rebuild ) this.calcWidth += cursorTile.width; // cursor end pos
+		if( rebuild ) {
+			this.calcWidth += cursorTile.width; // cursor end pos
+			if( inputWidth != null && this.calcWidth > inputWidth ) this.calcWidth = inputWidth;
+		}
 	}
 
 	function textPos( x : Float, y : Float ) {