Przeglądaj źródła

scroll text content when cursor outside

ncannasse 11 lat temu
rodzic
commit
c8f2345118
1 zmienionych plików z 6 dodań i 0 usunięć
  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;
 	}