Ver Fonte

fix focus() when cursor not yet set

Nicolas Cannasse há 6 anos atrás
pai
commit
8c39219bae
1 ficheiros alterados com 4 adições e 0 exclusões
  1. 4 0
      h2d/TextInput.hx

+ 4 - 0
h2d/TextInput.hx

@@ -336,6 +336,10 @@ class TextInput extends Text {
 
 	public function focus() {
 		interactive.focus();
+		if( cursorIndex < 0 ) {
+			cursorIndex = 0;
+			if( text != "" ) selectionRange = { start : 0, length : text.length };
+		}
 	}
 
 	public function hasFocus() {