Explorar o código

scroll text content when cursor outside

ncannasse %!s(int64=11) %!d(string=hai) anos
pai
achega
c8f2345118
Modificáronse 1 ficheiros con 6 adicións e 0 borrados
  1. 6 0
      h2d/comp/Input.hx

+ 6 - 0
h2d/comp/Input.hx

@@ -66,7 +66,13 @@ class Input extends Interactive {
 	}
 	
 	function set_cursorPos(v:Int) {
+		textAlign(tf);
 		cursor.x = tf.x + tf.calcTextWidth(value.substr(0, v)) + extLeft();
+		if( cursor.x > width - 4 ) {
+			var dx = cursor.x - (width - 4);
+			tf.x -= dx;
+			cursor.x -= dx;
+		}
 		return cursorPos = v;
 	}