Browse Source

fixed calcMaxWidth with inputWidth defined

ncannasse 8 năm trước cách đây
mục cha
commit
e22e314ab6
1 tập tin đã thay đổi với 4 bổ sung1 xóa
  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 ) {