diff options
| author | Jens Mönig <jens@moenig.org> | 2015-03-21 11:12:43 +0100 |
|---|---|---|
| committer | Jens Mönig <jens@moenig.org> | 2015-03-21 11:12:43 +0100 |
| commit | 4acf1896bd9fa57d3dbe3f4721b6790c6f3b0d56 (patch) | |
| tree | 8d44be9ed6bb5458d4354d59200783669dbc5cb2 /gui.js | |
| parent | fdd2ecf7d91d8026d3ca42c4bd52774877c72645 (diff) | |
| download | snap-4acf1896bd9fa57d3dbe3f4721b6790c6f3b0d56.tar.gz snap-4acf1896bd9fa57d3dbe3f4721b6790c6f3b0d56.zip | |
Prototypal inheritance of sprite-local variables
(experimental) slotwise inheritance à la Henry Lieberman for
sprite-local variables.
see
http://web.media.mit.edu/~lieber/Lieberary/OOP/Delegation/Delegation.htm
l
Let a sprite inherit another sprite’s local variables by making it the
“parent” in the sprite-icon’s context menu (the button icon in the
sprite corral underneath the stage). The child not only inherits the
variable slot but also - dynamically - the parent variable’s value.
Changing the parent’s variable value also changes it for every child.
If a child uses SET or CHANGE on an inherited variable it automatically
“shadows” it with its own value, thereby stopping dynamic participation
in the parent slot’s value (in effect dis-inheriting that slot).
Deleting a shadowed variable slot once again reinstates its inheritance
status.
inherited variables are shown as “ghosted” both in the child’s
variables palette and in such stage watchers. “Shadowing” them
un-ghosts both the variable blob template in the palette and the
watcher onstage (if any). Deleting a shadowed variable once again
ghosts the watcher and the palette block template.
Delete a (shadowed) variable either via the “Delete a variable” button
in the IDE or using the new “Delete” block in the variables category
Diffstat (limited to 'gui.js')
| -rw-r--r-- | gui.js | 18 |
1 files changed, 14 insertions, 4 deletions
@@ -69,7 +69,7 @@ SpeechBubbleMorph*/ // Global stuff //////////////////////////////////////////////////////// -modules.gui = '2015-March-15'; +modules.gui = '2015-March-21'; // Declarations @@ -2598,7 +2598,7 @@ IDE_Morph.prototype.aboutSnap = function () { module, btn1, btn2, btn3, btn4, licenseBtn, translatorsBtn, world = this.world(); - aboutTxt = 'Snap! 4.0\nBuild Your Own Blocks\n\n--- rc ---\n\n' + aboutTxt = 'Snap! 4.1 (OOP)\nBuild Your Own Blocks\n\n--- dev ---\n\n' + 'Copyright \u24B8 2015 Jens M\u00F6nig and ' + 'Brian Harvey\n' + 'jens@moenig.org, bh@cs.berkeley.edu\n\n' @@ -5182,7 +5182,7 @@ function SpriteIconMorph(aSprite, aTemplate) { } SpriteIconMorph.prototype.init = function (aSprite, aTemplate) { - var colors, action, query, myself = this; + var colors, action, query, hover, myself = this; if (!aTemplate) { colors = [ @@ -5212,6 +5212,11 @@ SpriteIconMorph.prototype.init = function (aSprite, aTemplate) { return false; }; + hover = function () { + if (!aSprite.exemplar) {return null; } + return (localize('parent' + ':\n' + aSprite.exemplar.name)); + }; + // additional properties: this.object = aSprite || new SpriteMorph(); // mandatory, actually this.version = this.object.version; @@ -5227,7 +5232,7 @@ SpriteIconMorph.prototype.init = function (aSprite, aTemplate) { this.object.name, // label string query, // predicate/selector null, // environment - null, // hint + hover, // hint aTemplate // optional, for cached background images ); @@ -5398,6 +5403,7 @@ SpriteIconMorph.prototype.userMenu = function () { menu.addItem("duplicate", 'duplicateSprite'); menu.addItem("delete", 'removeSprite'); menu.addLine(); + menu.addItem("parent...", 'chooseExemplar'); if (this.object.anchor) { menu.addItem( localize('detach from') + ' ' + this.object.anchor.name, @@ -5432,6 +5438,10 @@ SpriteIconMorph.prototype.exportSprite = function () { this.object.exportSprite(); }; +SpriteIconMorph.prototype.chooseExemplar = function () { + this.object.chooseExemplar(); +}; + SpriteIconMorph.prototype.showSpriteOnStage = function () { this.object.showOnStage(); }; |
