From d810518ce51988db760b2b86ad2a52cc370902ab Mon Sep 17 00:00:00 2001 From: Alan Knowles Date: Mon, 1 Nov 2010 11:24:03 +0800 Subject: [PATCH] Sample/Editor.js --- Sample/Editor.js | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/Sample/Editor.js b/Sample/Editor.js index 67ca9b648..784600718 100644 --- a/Sample/Editor.js +++ b/Sample/Editor.js @@ -14,6 +14,10 @@ Editor=new XObject({ xtype: Gtk.Window, listeners : { destroy_event : function (self, event) { + if (!this.get('/Editor.buffer').checkSyntax) { + // no hiding with errors. + return true; + } this.el.hide(); return true; }, @@ -54,6 +58,7 @@ Editor=new XObject({ xtype: Gtk.Button, listeners : { clicked : function (self) { + this.get('/Editor.RightEditor').save(); } }, @@ -67,10 +72,16 @@ Editor=new XObject({ id : "RightEditor", pack : "add", save : function() { - var str = this.get('/Editor.buffer').toString(); + var str = this.get('/Editor.buffer').toString(); + if (!this.get('/Editor.buffer').checkSyntax()) { + this.get('/StandardErrorDialog').show("Fix errors in code and save.."); + return false; + } + this.get('/LeftPanel.model').changed( str , false); this.get('/Editor').dirty = false; this.get('/Editor.save_button').el.sensitive = false; + return true; }, items : [ { @@ -132,7 +143,7 @@ Editor=new XObject({ }, save : function() { - this.get('/Editor.RightEditor').save(); + return this.get('/Editor.RightEditor').save(); }, show_line_numbers : true, items : [ -- 2.39.2