Procházet zdrojové kódy

CodeEditor: auto-save on blur, propagate scroll again

trethaller před 4 roky
rodič
revize
4acea00205

+ 1 - 3
hide/comp/CodeEditor.hx

@@ -28,13 +28,11 @@ class CodeEditor extends Component {
 			mouseWheelZoom: true,
 			scrollBeyondLastLine: false
 		});
-		root.on("mousewheel", function(e) {
-			return false;
-		});
 		var model = editor.getModel();
 		(model : Dynamic).__comp__ = this;
 		model.updateOptions({ insertSpaces:false, trimAutoWhitespace:true });
 		editor.onDidChangeModelContent(function() onChanged());
+		editor.onDidBlurEditorText(function() onSave());
 		editor.addCommand(monaco.KeyCode.KEY_S | monaco.KeyMod.CtrlCmd, function() { clearSpaces(); onSave(); });
 		errorMessage = new Element('<div class="codeErrorMessage"></div>').appendTo(root).hide();
 	}

+ 0 - 5
hide/comp/cdb/ScriptTable.hx

@@ -59,11 +59,6 @@ class ScriptTable extends SubTable {
 		]);
 		script = new ScriptEditor(cell.value, checker, div);
 		script.onSave = saveValue;
-		var onChanged = script.onChanged;
-		script.onChanged = function() {
-			if( onChanged != null ) onChanged();
-			saveValue();
-		}
 		script.propagateKeys = true;
 		script.onClose = function() { close(); cell.focus(); }
 		lines = [new Line(this,[],0,script.element)];

+ 2 - 0
libs/monaco/ScriptEditor.hx

@@ -7,6 +7,8 @@ extern class ScriptEditor {
 	function addCommand( command : Int, callback : Void -> Void ) : Void;
 	function getValue( ?options : { ?lineEnding : String, ?preserveBOM : Bool } ) : String;
 	function onDidChangeModelContent( listener : Void -> Void ) : Void;
+	function onDidBlurEditorText( listener : Void -> Void ) : Void;
+	function onDidFocusEditorText( listener : Void -> Void ) : Void;
 	function focus() : Void;
 	function dispose() : Void;
 	function getModel() : Model;