kopia lustrzana https://github.com/backface/turtlestitch
added Node >> childThatIsA
rodzic
849757db52
commit
b19927868b
|
@ -1291,7 +1291,7 @@
|
|||
|
||||
/*jshint esversion: 6*/
|
||||
|
||||
var morphicVersion = '2022-January-22';
|
||||
var morphicVersion = '2022-January-23';
|
||||
var modules = {}; // keep track of additional loaded modules
|
||||
var useBlurredShadows = true;
|
||||
|
||||
|
@ -3098,6 +3098,27 @@ Node.prototype.parentThatIsAnyOf = function (constructors) {
|
|||
return this.parentThatIsA.apply(this, constructors);
|
||||
};
|
||||
|
||||
Node.prototype.childThatIsA = function () {
|
||||
// including myself
|
||||
// Note: you can pass in multiple constructors to test for
|
||||
var i, hit;
|
||||
for (i = 0; i < arguments.length; i += 1) {
|
||||
if (this instanceof arguments[i]) {
|
||||
return this;
|
||||
}
|
||||
}
|
||||
if (!this.children.length) {
|
||||
return null;
|
||||
}
|
||||
for (i = 0; i < this.children.length; i += 1) {
|
||||
hit = this.childThatIsA.apply(this.children[i], arguments);
|
||||
if (hit) {
|
||||
return hit;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
};
|
||||
|
||||
// Morphs //////////////////////////////////////////////////////////////
|
||||
|
||||
// Morph: referenced constructors
|
||||
|
|
|
@ -10058,7 +10058,8 @@ SpriteBubbleMorph.prototype.dataAsMorph = function (data) {
|
|||
contents.selectForEdit = function () {
|
||||
var script = data.toBlock(),
|
||||
prepare = script.prepareToBeGrabbed,
|
||||
ide = this.parentThatIsA(IDE_Morph);
|
||||
ide = this.parentThatIsA(IDE_Morph)||
|
||||
this.world().childThatIsA(IDE_Morph);
|
||||
|
||||
script.prepareToBeGrabbed = function (hand) {
|
||||
prepare.call(this, hand);
|
||||
|
@ -11460,7 +11461,8 @@ CellMorph.prototype.createContents = function () {
|
|||
this.contentsMorph.selectForEdit = function () {
|
||||
var script = myself.contents.toBlock(),
|
||||
prepare = script.prepareToBeGrabbed,
|
||||
ide = this.parentThatIsA(IDE_Morph);
|
||||
ide = this.parentThatIsA(IDE_Morph) ||
|
||||
this.world().childThatIsA(IDE_Morph); // +++
|
||||
|
||||
script.prepareToBeGrabbed = function (hand) {
|
||||
prepare.call(this, hand);
|
||||
|
|
Ładowanie…
Reference in New Issue