kopia lustrzana https://github.com/backface/turtlestitch
responses to Michael's review
rodzic
51aa5db3b0
commit
fda6938f29
23
blocks.js
23
blocks.js
|
@ -7533,7 +7533,7 @@ InputSlotMorph.prototype.setContents = function (aStringOrFloat) {
|
||||||
InputSlotMorph.prototype.dropDownMenu = function (enableKeyboard) {
|
InputSlotMorph.prototype.dropDownMenu = function (enableKeyboard) {
|
||||||
var choices = this.choices,
|
var choices = this.choices,
|
||||||
key,
|
key,
|
||||||
menustack = [],
|
menuStack = [],
|
||||||
menu = new MenuMorph(
|
menu = new MenuMorph(
|
||||||
this.setContents,
|
this.setContents,
|
||||||
null,
|
null,
|
||||||
|
@ -7556,10 +7556,12 @@ InputSlotMorph.prototype.dropDownMenu = function (enableKeyboard) {
|
||||||
menu.addLine();
|
menu.addLine();
|
||||||
// } else if (key.indexOf('§_def') === 0) {
|
// } else if (key.indexOf('§_def') === 0) {
|
||||||
// menu.addItem(choices[key].blockInstance(), choices[key]);
|
// menu.addItem(choices[key].blockInstance(), choices[key]);
|
||||||
} else if (key.charCodeAt(key.length-1) == 0x25ba) {
|
} else if (key.charCodeAt(key.length - 1) == 0x25ba) {
|
||||||
// Submenu
|
// Submenu
|
||||||
|
// 0x25ba = Unicode "BLACK RIGHT-POINTING POINTER"
|
||||||
|
// (not to be confused with "black right-pointing TRIANGLE")
|
||||||
menu.addItem(key, choices[key]);
|
menu.addItem(key, choices[key]);
|
||||||
menustack.push(menu);
|
menuStack.push(menu);
|
||||||
menu = new MenuMorph(
|
menu = new MenuMorph(
|
||||||
this.setContents,
|
this.setContents,
|
||||||
null,
|
null,
|
||||||
|
@ -7567,23 +7569,24 @@ InputSlotMorph.prototype.dropDownMenu = function (enableKeyboard) {
|
||||||
this.fontSize
|
this.fontSize
|
||||||
);
|
);
|
||||||
} else if (key.charCodeAt(0) == 0x25c4) {
|
} else if (key.charCodeAt(0) == 0x25c4) {
|
||||||
var oldmenu=menustack[menustack.length-1],
|
// "BLACK LEFT-POINTING POINTER"
|
||||||
items=oldmenu.items;
|
var oldmenu = menuStack[menuStack.length - 1],
|
||||||
items[items.length-1][6] = menu;
|
items = oldmenu.items;
|
||||||
|
items[items.length - 1][6] = menu;
|
||||||
oldmenu.addChild(menu);
|
oldmenu.addChild(menu);
|
||||||
menu = menustack.pop();
|
menu = menuStack.pop();
|
||||||
} else {
|
} else {
|
||||||
menu.addItem(key, choices[key]);
|
menu.addItem(key, choices[key]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
while (menustack.length > 0) {
|
while (menuStack.length > 0) {
|
||||||
var oldmenu=menustack[menustack.length-1],
|
var oldmenu=menuStack[menuStack.length - 1],
|
||||||
items=oldmenu.items;
|
items=oldmenu.items;
|
||||||
items[items.length-1][6] = menu;
|
items[items.length-1][6] = menu;
|
||||||
oldmenu.addChild(menu);
|
oldmenu.addChild(menu);
|
||||||
menu = menustack.pop();
|
menu = menuStack.pop();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (menu.items.length > 0) {
|
if (menu.items.length > 0) {
|
||||||
|
|
57
morphic.js
57
morphic.js
|
@ -7683,6 +7683,10 @@ MenuMorph.prototype.unselectAllItems = function () {
|
||||||
};
|
};
|
||||||
|
|
||||||
MenuMorph.prototype.popup = function (world, pos, submenu) {
|
MenuMorph.prototype.popup = function (world, pos, submenu) {
|
||||||
|
// submenu is True if this menu is a submenu,
|
||||||
|
// so that we don't make it the world's activeMenu nor
|
||||||
|
// destroy its parent menu.
|
||||||
|
|
||||||
this.drawNew();
|
this.drawNew();
|
||||||
this.setPosition(pos);
|
this.setPosition(pos);
|
||||||
this.addShadow(new Point(2, 2), 80);
|
this.addShadow(new Point(2, 2), 80);
|
||||||
|
@ -7823,22 +7827,19 @@ MenuMorph.prototype.select = function (aMenuItem) {
|
||||||
MenuMorph.prototype.mouseLeave = function () {
|
MenuMorph.prototype.mouseLeave = function () {
|
||||||
if (this.parent instanceof MenuMorph) {
|
if (this.parent instanceof MenuMorph) {
|
||||||
// this is a submenu so we vanish when lose focus
|
// this is a submenu so we vanish when lose focus
|
||||||
var mouses = this.world.hand.allMorphsAtPointer();
|
this.destroy();
|
||||||
if (contains(mouses, this.parent)) {
|
|
||||||
var items = mouses.filter(function (morph)
|
|
||||||
{return morph instanceof MenuItemMorph});
|
|
||||||
if (items[0].doubleClickAction != this) {
|
|
||||||
this.destroy();
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
this.destroy();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
MenuMorph.prototype.destroy = function () {
|
MenuMorph.prototype.destroy = function () {
|
||||||
var myself = this;
|
var myself = this,
|
||||||
|
subitems = function(menu) {
|
||||||
|
return menu.children.filter(function (child) {
|
||||||
|
return (child instanceof MenuItemMorph) &&
|
||||||
|
(child.doubleClickAction instanceof MenuMorph);
|
||||||
|
} )
|
||||||
|
};
|
||||||
|
|
||||||
if (this.hasFocus) {
|
if (this.hasFocus) {
|
||||||
this.world.keyboardReceiver = null;
|
this.world.keyboardReceiver = null;
|
||||||
|
@ -7846,21 +7847,17 @@ var myself = this;
|
||||||
|
|
||||||
if ((this.parent instanceof MenuMorph) && this.world) {
|
if ((this.parent instanceof MenuMorph) && this.world) {
|
||||||
// If I'm a submenu, un-highlight the item pointing to me.
|
// If I'm a submenu, un-highlight the item pointing to me.
|
||||||
var mouses = this.world.hand.allMorphsAtPointer(),
|
subitems(this.parent).forEach(function (item) {
|
||||||
items = this.parent.children.filter(function (child) {
|
item.image = item.normalImage;
|
||||||
return (child instanceof MenuItemMorph) &&
|
item.changed();
|
||||||
(child.doubleClickAction instanceof MenuMorph) &&
|
} );
|
||||||
!(contains(mouses, child)); });
|
};
|
||||||
items.forEach(function (item) {item.image = item.normalImage;
|
|
||||||
item.changed(); });
|
|
||||||
}
|
|
||||||
|
|
||||||
// Also kill my submenus if any.
|
// Also kill my submenus if any.
|
||||||
var triggers = this.children.filter(function (each) {
|
subitems(this).forEach(function (item) {
|
||||||
return (each instanceof MenuItemMorph) &&
|
item.doubleClickAction.destroy();
|
||||||
(each.doubleClickAction instanceof MenuMorph);
|
});
|
||||||
});
|
|
||||||
triggers.forEach(function (item) {item.doubleClickAction.destroy();});
|
|
||||||
MenuMorph.uber.destroy.call(this);
|
MenuMorph.uber.destroy.call(this);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -9443,7 +9440,7 @@ MenuItemMorph.prototype.mouseEnter = function () {
|
||||||
this.changed();
|
this.changed();
|
||||||
}
|
}
|
||||||
if (this.doubleClickAction instanceof MenuMorph) {
|
if (this.doubleClickAction instanceof MenuMorph) {
|
||||||
var w=this.parentThatIsA(WorldMorph);
|
var w = this.parentThatIsA(WorldMorph);
|
||||||
this.doubleClickAction.popup(w,
|
this.doubleClickAction.popup(w,
|
||||||
new Point(this.parent.bounds.right()-10,
|
new Point(this.parent.bounds.right()-10,
|
||||||
w.hand.position().y-10),
|
w.hand.position().y-10),
|
||||||
|
@ -9459,11 +9456,11 @@ MenuItemMorph.prototype.mouseEnter = function () {
|
||||||
MenuItemMorph.prototype.mouseLeave = function () {
|
MenuItemMorph.prototype.mouseLeave = function () {
|
||||||
if (this.doubleClickAction instanceof MenuMorph) {
|
if (this.doubleClickAction instanceof MenuMorph) {
|
||||||
if (!contains(this.world().hand.allMorphsAtPointer(),
|
if (!contains(this.world().hand.allMorphsAtPointer(),
|
||||||
this.doubleClickAction)) {
|
this.doubleClickAction)) {
|
||||||
this.doubleClickAction.destroy();
|
this.doubleClickAction.destroy();
|
||||||
this.image = this.normalImage;
|
this.image = this.normalImage;
|
||||||
this.changed();
|
this.changed();
|
||||||
}
|
}
|
||||||
} else if (!this.isListItem()) {
|
} else if (!this.isListItem()) {
|
||||||
this.image = this.normalImage;
|
this.image = this.normalImage;
|
||||||
this.changed();
|
this.changed();
|
||||||
|
|
Ładowanie…
Reference in New Issue