From 7eb778a98e08e4c79a73ed41be6beafa1fda5788 Mon Sep 17 00:00:00 2001 From: Jens Mönig Date: Wed, 15 Apr 2015 17:02:10 +0200 Subject: flush Stage>>keysPressed when prompting the user --- history.txt | 5 +++++ threads.js | 3 ++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/history.txt b/history.txt index 8a2066d..ef96624 100755 --- a/history.txt +++ b/history.txt @@ -2493,3 +2493,8 @@ ______ ------ * Threads: fixed #752 * OOP: integrated and adjusted fix for #752 + +150415 +------ +* Threads: flush Stage>>keysPressed when prompting the user + diff --git a/threads.js b/threads.js index 52f464d..6ba0442 100644 --- a/threads.js +++ b/threads.js @@ -83,7 +83,7 @@ ArgLabelMorph, localize, XML_Element, hex_sha512*/ // Global stuff //////////////////////////////////////////////////////// -modules.threads = '2015-March-25'; +modules.threads = '2015-April-15'; var ThreadManager; var Process; @@ -1835,6 +1835,7 @@ Process.prototype.doAsk = function (data) { isStage = this.blockReceiver() instanceof StageMorph, activePrompter; + stage.keysPressed = {}; if (!this.prompter) { activePrompter = detect( stage.children, -- cgit v1.3.1 From 4f39a406da6dbbea1ae6a34cfcbc1026ef6ad6aa Mon Sep 17 00:00:00 2001 From: Jens Mönig Date: Wed, 15 Apr 2015 17:32:08 +0200 Subject: fixed #770 --- history.txt | 2 +- objects.js | 29 ++++++++++++++++++++++++++--- 2 files changed, 27 insertions(+), 4 deletions(-) diff --git a/history.txt b/history.txt index ef96624..b3b4da3 100755 --- a/history.txt +++ b/history.txt @@ -2497,4 +2497,4 @@ ______ 150415 ------ * Threads: flush Stage>>keysPressed when prompting the user - +* Objects: fixed #770 diff --git a/objects.js b/objects.js index 66726a1..173be51 100644 --- a/objects.js +++ b/objects.js @@ -125,7 +125,7 @@ PrototypeHatBlockMorph*/ // Global stuff //////////////////////////////////////////////////////// -modules.objects = '2015-March-24'; +modules.objects = '2015-April-15'; var SpriteMorph; var StageMorph; @@ -2369,6 +2369,29 @@ SpriteMorph.prototype.freshPalette = function (category) { } }); + // inherited custom blocks: (under construction...) + + // y += unit * 1.6; + if (this.exemplar) { + this.exemplar.customBlocks.forEach(function (definition) { + var block; + if (definition.category === category || + (category === 'variables' + && contains( + ['lists', 'other'], + definition.category + ))) { + block = definition.templateInstance(); + y += unit * 0.3; + block.setPosition(new Point(x, y)); + palette.addContents(block); + block.ghost(); + x = 0; + y += block.height(); + } + }); + } + //layout palette.scrollX(palette.padding); @@ -3107,7 +3130,7 @@ SpriteMorph.prototype.setEffect = function (effect, value) { if (eff === 'ghost') { this.alpha = 1 - Math.min(Math.max(+value || 0, 0), 100) / 100; } else { - this.graphicsValues[eff] = value; + this.graphicsValues[eff] = +value; } this.drawNew(); this.changed(); @@ -3122,7 +3145,7 @@ SpriteMorph.prototype.changeEffect = function (effect, value) { if (eff === 'ghost') { this.setEffect(effect, this.getGhostEffect() + (+value || 0)); } else { - this.setEffect(effect, this.graphicsValues[eff] + value); + this.setEffect(effect, +this.graphicsValues[eff] + (+value)); } }; -- cgit v1.3.1 From 9e4b73eae9adcbad1cef270411b56d0676cf0006 Mon Sep 17 00:00:00 2001 From: Jens Mönig Date: Fri, 17 Apr 2015 15:27:29 +0200 Subject: OOP: Prototypal inheritance of sprite-local custom blocks (palette only) --- history.txt | 4 ++++ objects.js | 46 ++++++++++++++++++++++++++++++++++++++++++++-- 2 files changed, 48 insertions(+), 2 deletions(-) diff --git a/history.txt b/history.txt index b3b4da3..938213e 100755 --- a/history.txt +++ b/history.txt @@ -2498,3 +2498,7 @@ ______ ------ * Threads: flush Stage>>keysPressed when prompting the user * Objects: fixed #770 + +150415 +------ +* OOP: Objects, Prototypal inheritance of sprite-local custom blocks (palette only) diff --git a/objects.js b/objects.js index 173be51..52292ca 100644 --- a/objects.js +++ b/objects.js @@ -125,7 +125,7 @@ PrototypeHatBlockMorph*/ // Global stuff //////////////////////////////////////////////////////// -modules.objects = '2015-April-15'; +modules.objects = '2015-April-17'; var SpriteMorph; var StageMorph; @@ -2373,7 +2373,7 @@ SpriteMorph.prototype.freshPalette = function (category) { // y += unit * 1.6; if (this.exemplar) { - this.exemplar.customBlocks.forEach(function (definition) { + this.inheritedBlocks(true).forEach(function (definition) { var block; if (definition.category === category || (category === 'variables' @@ -4284,6 +4284,48 @@ SpriteMorph.prototype.deletableVariableNames = function () { ); }; +// SpriteMorph inheritance - custom blocks + +SpriteMorph.prototype.ownBlocks = function () { + var dict = {}; + this.customBlocks.forEach(function (def) { + dict[def.blockSpec()] = def; + }); + return dict; +}; + +SpriteMorph.prototype.allBlocks = function (valuesOnly) { + var dict = {}; + this.allExemplars().reverse().forEach(function (sprite) { + sprite.customBlocks.forEach(function (def) { + dict[def.blockSpec()] = def; + }); + }); + if (valuesOnly) { + return Object.keys(dict).map(function (key) {return dict[key]; }); + } + return dict; +}; + +SpriteMorph.prototype.inheritedBlocks = function (valuesOnly) { + var dict = {}, + own = Object.keys(this.ownBlocks()), + others = this.allExemplars().reverse(); + others.pop(); + others.forEach(function (sprite) { + sprite.customBlocks.forEach(function (def) { + var spec = def.blockSpec(); + if (!contains(own, spec)) { + dict[spec] = def; + } + }); + }); + if (valuesOnly) { + return Object.keys(dict).map(function (key) {return dict[key]; }); + } + return dict; +}; + // SpriteMorph highlighting SpriteMorph.prototype.addHighlight = function (oldHighlight) { -- cgit v1.3.1 From 340f91b7f2c46e0068562935c7277054d779e1bf Mon Sep 17 00:00:00 2001 From: Jens Mönig Date: Fri, 1 May 2015 11:50:59 -0400 Subject: Morphic: event hook for first mouse click on editable text --- morphic.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/morphic.js b/morphic.js index c725209..2850e32 100644 --- a/morphic.js +++ b/morphic.js @@ -1048,7 +1048,7 @@ /*global window, HTMLCanvasElement, getMinimumFontHeight, FileReader, Audio, FileList, getBlurredShadowSupport*/ -var morphicVersion = '2015-March-24'; +var morphicVersion = '2015-May-01'; var modules = {}; // keep track of additional loaded modules var useBlurredShadows = getBlurredShadowSupport(); // check for Chrome-bug @@ -7454,6 +7454,8 @@ StringMorph.prototype.mouseClickLeft = function (pos) { StringMorph.prototype.enableSelecting = function () { this.mouseDownLeft = function (pos) { + var crs = this.root().cursor, + already = crs ? crs.target === this : false; this.clearSelection(); if (this.isEditable && (!this.isDraggable)) { this.edit(); @@ -7461,6 +7463,7 @@ StringMorph.prototype.enableSelecting = function () { this.startMark = this.slotAt(pos); this.endMark = this.startMark; this.currentlySelecting = true; + if (!already) {this.escalateEvent('mouseDownLeft', pos); } } }; this.mouseMove = function (pos) { -- cgit v1.3.1 From 4d5b9ca135233a23b556fd2f07e0ff6bd8a0bd74 Mon Sep 17 00:00:00 2001 From: Jens Mönig Date: Fri, 1 May 2015 11:55:33 -0400 Subject: select all text when first clicking an input slot --- blocks.js | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/blocks.js b/blocks.js index 45f1049..8049e59 100644 --- a/blocks.js +++ b/blocks.js @@ -155,7 +155,7 @@ DialogBoxMorph, BlockInputFragmentMorph, PrototypeHatBlockMorph, Costume*/ // Global stuff //////////////////////////////////////////////////////// -modules.blocks = '2015-March-23'; +modules.blocks = '2015-May-01'; var SyntaxElementMorph; @@ -7022,6 +7022,15 @@ InputSlotMorph.prototype.fixLayout = function () { // InputSlotMorph events: +InputSlotMorph.prototype.mouseDownLeft = function (pos) { + if (this.isReadOnly || this.arrow().bounds.containsPoint(pos)) { + this.escalateEvent('mouseDownLeft', pos); + } else { + this.contents().edit(); + this.contents().selectAll(); + } +}; + InputSlotMorph.prototype.mouseClickLeft = function (pos) { if (this.arrow().bounds.containsPoint(pos)) { this.dropDownMenu(); -- cgit v1.3.1 From 86e4170a571455d3f828fd2b1161313b3126beef Mon Sep 17 00:00:00 2001 From: Jens Mönig Date: Fri, 1 May 2015 11:57:12 -0400 Subject: indicate numeric inputs in the block prototype with the # sign --- byob.js | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/byob.js b/byob.js index c9f3daa..bc0f75f 100644 --- a/byob.js +++ b/byob.js @@ -106,7 +106,7 @@ SymbolMorph, isNil*/ // Global stuff //////////////////////////////////////////////////////// -modules.byob = '2015-March-02'; +modules.byob = '2015-May-01'; // Declarations @@ -2049,7 +2049,13 @@ BlockLabelFragment.prototype.defTemplateSpecFragment = function () { )) { suff = ' \u03BB'; } else if (this.defaultValue) { - suff = ' = ' + this.defaultValue.toString(); + if (this.type === '%n') { + suff = ' # = ' + this.defaultValue.toString(); + } else { // 'any' or 'text' + suff = ' = ' + this.defaultValue.toString(); + } + } else if (this.type === '%n') { + suff = ' #'; } return this.labelString + suff; }; -- cgit v1.3.1 From d96a5984e64cdd2e8c4abcd0abaabaadf7cc1c02 Mon Sep 17 00:00:00 2001 From: Jens Mönig Date: Fri, 1 May 2015 11:59:51 -0400 Subject: return empty string when querying first letter of a list --- threads.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/threads.js b/threads.js index 6ba0442..47d5616 100644 --- a/threads.js +++ b/threads.js @@ -83,7 +83,7 @@ ArgLabelMorph, localize, XML_Element, hex_sha512*/ // Global stuff //////////////////////////////////////////////////////// -modules.threads = '2015-April-15'; +modules.threads = '2015-May-01'; var ThreadManager; var Process; @@ -2204,6 +2204,9 @@ Process.prototype.reportJoinWords = function (aList) { // Process string ops Process.prototype.reportLetter = function (idx, string) { + if (string instanceof List) { // catch a common user error + return ''; + } var i = +(idx || 0), str = (string || '').toString(); return str[i - 1] || ''; -- cgit v1.3.1 From 1f9d5d384d73432c42e711eb05bb2ff9a31e9b34 Mon Sep 17 00:00:00 2001 From: Jens Mönig Date: Fri, 1 May 2015 12:01:51 -0400 Subject: hide “save to disk” option behind shift-click again (has issues in Chrome) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- gui.js | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/gui.js b/gui.js index 4cd2a9b..69b4a9d 100644 --- a/gui.js +++ b/gui.js @@ -69,7 +69,7 @@ SpeechBubbleMorph*/ // Global stuff //////////////////////////////////////////////////////// -modules.gui = '2015-March-21'; +modules.gui = '2015-May-01'; // Declarations @@ -2384,12 +2384,15 @@ IDE_Morph.prototype.projectMenu = function () { menu.addItem('New', 'createNewProject'); menu.addItem('Open...', 'openProjectsBrowser'); menu.addItem('Save', "save"); - menu.addItem( - 'Save to disk', - 'saveProjectToDisk', - 'store this project\nin the downloads folder\n' - + '(in supporting browsers)' - ); + if (shiftClicked) { + menu.addItem( + 'Save to disk', + 'saveProjectToDisk', + 'store this project\nin the downloads folder\n' + + '(in supporting browsers)', + new Color(100, 0, 0) + ); + } menu.addItem('Save As...', 'saveProjectsBrowser'); menu.addLine(); menu.addItem( -- cgit v1.3.1 From 8fa2b2c1f2d1b8d0b71204a7fb4a8b783762ff1a Mon Sep 17 00:00:00 2001 From: Jens Mönig Date: Fri, 1 May 2015 12:18:16 -0400 Subject: parameters for embedding projects Thanks, Bernat! --- gui.js | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/gui.js b/gui.js index 69b4a9d..0d866b4 100644 --- a/gui.js +++ b/gui.js @@ -384,8 +384,21 @@ IDE_Morph.prototype.openIn = function (world) { myself.shield.destroy(); myself.shield = null; msg.destroy(); - myself.toggleAppMode(true); - myself.runScripts(); + + if (dict.editMode) { + myself.toggleAppMode(false); + } else { + myself.toggleAppMode(true); + } + + if (!dict.noRun) { + myself.runScripts(); + } + + if (dict.hideControls) { + myself.controlBar.hide(); + window.onbeforeunload = function () {nop(); }; + } } ]); }, -- cgit v1.3.1 From 83628bc0aca42c078a96b0a6fbb2675cf6cae5c3 Mon Sep 17 00:00:00 2001 From: Jens Mönig Date: Fri, 1 May 2015 12:25:31 -0400 Subject: update history --- history.txt | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/history.txt b/history.txt index 938213e..7f60776 100755 --- a/history.txt +++ b/history.txt @@ -2502,3 +2502,11 @@ ______ 150415 ------ * OOP: Objects, Prototypal inheritance of sprite-local custom blocks (palette only) + +150501 +------ +* Morphic, Blocks: select all text when first clicking an input slot +* BYOB: indicate numeric inputs in the block prototype with the # sign +* Threads: return empty string when querying first letter of a list +* GUI: hide “save to disk” option behind shift-click again (has issues in Chrome) +* GUI: parameters for embedding projects in iFrames, thanks, Bernat! -- cgit v1.3.1