Parcourir la source

UI.TextArea: Handle tabs.

Mr.doob il y a 11 ans
Parent
commit
be6276e84d
1 fichiers modifiés avec 12 ajouts et 0 suppressions
  1. 12 0
      editor/js/libs/ui.js

+ 12 - 0
editor/js/libs/ui.js

@@ -359,6 +359,18 @@ UI.TextArea = function () {
 
 		event.stopPropagation();
 
+		if ( event.keyCode === 9 ) {
+
+			event.preventDefault();
+
+			var cursor = dom.selectionStart;
+
+			dom.value = dom.value.substring( 0, cursor ) + '\t' + dom.value.substring( cursor );
+			dom.selectionStart = cursor + 1;
+			dom.selectionEnd = dom.selectionStart;
+
+		}
+
 	}, false );
 
 	this.dom = dom;