Browse Source

UI.TextArea: Handle tabs.

Mr.doob 11 years ago
parent
commit
be6276e84d
1 changed files with 12 additions and 0 deletions
  1. 12 0
      editor/js/libs/ui.js

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

@@ -359,6 +359,18 @@ UI.TextArea = function () {
 
 
 		event.stopPropagation();
 		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 );
 	}, false );
 
 
 	this.dom = dom;
 	this.dom = dom;