diff --git a/app/src/processing/mode/javascript/JavaScriptEditor.java b/app/src/processing/mode/javascript/JavaScriptEditor.java index 8eada7954..1e8ee7f5e 100644 --- a/app/src/processing/mode/javascript/JavaScriptEditor.java +++ b/app/src/processing/mode/javascript/JavaScriptEditor.java @@ -280,7 +280,9 @@ public class JavaScriptEditor extends Editor */ public void handleStartServer () { - handleExport( false ); + statusEmpty(); + boolean success = handleExport( false ); + if ( !success ) return; File serverRoot = new File(sketch.getFolder(), JavaScriptBuild.EXPORTED_FOLDER_NAME); @@ -338,25 +340,29 @@ public class JavaScriptEditor extends Editor /** * Call the export method of the sketch and handle the gui stuff */ - public void handleExport ( boolean openFolder ) + public boolean handleExport ( boolean openFolder ) { - if (handleExportCheckModified()) { + if (handleExportCheckModified()) + { toolbar.activate(JavaScriptToolbar.EXPORT); try { boolean success = jsMode.handleExport(sketch); - if ( success && openFolder ) { + if ( success && openFolder ) + { File appletJSFolder = new File(sketch.getFolder(), JavaScriptBuild.EXPORTED_FOLDER_NAME ); Base.openFolder(appletJSFolder); statusNotice("Finished exporting."); - } else { - // error message already displayed by handleExport + } else if ( !success ) { + // error message already displayed by handleExport + return false; } } catch (Exception e) { statusError(e); } toolbar.deactivate(JavaScriptToolbar.EXPORT); } + return true; } /** diff --git a/javascript/examples/Environment/DocumentObjectModel/colorFinder/colorFinder.pde b/javascript/examples/Environment/DocumentObjectModel/colorFinder/colorFinder.pde index 4e11d1218..bf0a77107 100644 --- a/javascript/examples/Environment/DocumentObjectModel/colorFinder/colorFinder.pde +++ b/javascript/examples/Environment/DocumentObjectModel/colorFinder/colorFinder.pde @@ -23,10 +23,7 @@ void mouseDragged () colorMode(HSB); mColor = color( map(mouseX, 0,width, 0,255), 200, map(mouseY, 0, height, 255, 0) ); colorMode(RGB); -} - -void mouseReleased () -{ + if ( js ) { js.setColor(red(mColor), green(mColor), blue(mColor)); @@ -34,11 +31,11 @@ void mouseReleased () } /** - * Define an interface that will act as glue between your sketch - * and "real" JavaScript running in your page. The name does not matter. + * Define an interface that will act as glue between this sketch + * and "real" JavaScript running in the HTML page. The name does not matter. * - * The interface must define any functions that you intend to call - * from inside your sketch. + * The interface must define any functions that one intends to call + * from inside the sketch. */ interface JavaScriptInterface { diff --git a/javascript/examples/Environment/DocumentObjectModel/colorFinder/jsinterface.js b/javascript/examples/Environment/DocumentObjectModel/colorFinder/jsinterface.js index 27e161672..b44711305 100644 --- a/javascript/examples/Environment/DocumentObjectModel/colorFinder/jsinterface.js +++ b/javascript/examples/Environment/DocumentObjectModel/colorFinder/jsinterface.js @@ -1,6 +1,6 @@ /** - * This code will be embedded into your HTML page as "normal" - * JavaScript code with a