kopia lustrzana https://github.com/backface/turtlestitch
added “inherited” option to inheritable method templates’ context menu in the palette
rodzic
c4a05854f9
commit
3dd0433ae6
86
byob.js
86
byob.js
|
@ -108,7 +108,7 @@ BooleanSlotMorph, XML_Serializer*/
|
||||||
|
|
||||||
// Global stuff ////////////////////////////////////////////////////////
|
// Global stuff ////////////////////////////////////////////////////////
|
||||||
|
|
||||||
modules.byob = '2017-September-01';
|
modules.byob = '2017-September-19';
|
||||||
|
|
||||||
// Declarations
|
// Declarations
|
||||||
|
|
||||||
|
@ -885,6 +885,16 @@ CustomCommandBlockMorph.prototype.userMenu = function () {
|
||||||
shiftClicked = this.world().currentKey === 16,
|
shiftClicked = this.world().currentKey === 16,
|
||||||
menu;
|
menu;
|
||||||
|
|
||||||
|
function addOption(label, toggle, test, onHint, offHint) {
|
||||||
|
var on = '\u2611 ',
|
||||||
|
off = '\u2610 ';
|
||||||
|
menu.addItem(
|
||||||
|
(test ? on : off) + localize(label),
|
||||||
|
toggle,
|
||||||
|
test ? onHint : offHint
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
function monitor(vName) {
|
function monitor(vName) {
|
||||||
var stage = rcvr.parentThatIsA(StageMorph),
|
var stage = rcvr.parentThatIsA(StageMorph),
|
||||||
varFrame = myself.variables;
|
varFrame = myself.variables;
|
||||||
|
@ -973,17 +983,69 @@ CustomCommandBlockMorph.prototype.userMenu = function () {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
// if global or own method - let the user delete the definition
|
if (this.isTemplate) { // inside the palette
|
||||||
if (this.isGlobal ||
|
if (this.isGlobal) {
|
||||||
contains(
|
menu.addItem(
|
||||||
Object.keys(rcvr.ownBlocks()),
|
"delete block definition...",
|
||||||
this.blockSpec
|
'deleteBlockDefinition'
|
||||||
)
|
);
|
||||||
) {
|
} else { // local method
|
||||||
menu.addItem(
|
if (contains(
|
||||||
"delete block definition...",
|
Object.keys(rcvr.inheritedBlocks()),
|
||||||
'deleteBlockDefinition'
|
this.blockSpec
|
||||||
);
|
)) {
|
||||||
|
// inherited
|
||||||
|
addOption(
|
||||||
|
'inherited',
|
||||||
|
function () {
|
||||||
|
var ide = myself.parentThatIsA(IDE_Morph);
|
||||||
|
rcvr.customBlocks.push(
|
||||||
|
rcvr.getMethod(
|
||||||
|
myself.blockSpec
|
||||||
|
).copyAndBindTo(rcvr)
|
||||||
|
);
|
||||||
|
if (ide) {
|
||||||
|
ide.flushPaletteCache();
|
||||||
|
ide.refreshPalette();
|
||||||
|
}
|
||||||
|
},
|
||||||
|
true,
|
||||||
|
'uncheck to\ndisinherit',
|
||||||
|
null
|
||||||
|
);
|
||||||
|
} else if (rcvr.exemplar &&
|
||||||
|
rcvr.exemplar.getMethod(this.blockSpec
|
||||||
|
)) {
|
||||||
|
// shadowed
|
||||||
|
addOption(
|
||||||
|
'inherited',
|
||||||
|
'deleteBlockDefinition',
|
||||||
|
false,
|
||||||
|
null,
|
||||||
|
localize('check to inherit\nfrom')
|
||||||
|
+ ' ' + rcvr.exemplar.name
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
// own block
|
||||||
|
menu.addItem(
|
||||||
|
"delete block definition...",
|
||||||
|
'deleteBlockDefinition'
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else { // inside a script
|
||||||
|
// if global or own method - let the user delete the definition
|
||||||
|
if (this.isGlobal ||
|
||||||
|
contains(
|
||||||
|
Object.keys(rcvr.ownBlocks()),
|
||||||
|
this.blockSpec
|
||||||
|
)
|
||||||
|
) {
|
||||||
|
menu.addItem(
|
||||||
|
"delete block definition...",
|
||||||
|
'deleteBlockDefinition'
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
this.variables.names().forEach(function (vName) {
|
this.variables.names().forEach(function (vName) {
|
||||||
|
|
|
@ -3633,6 +3633,10 @@ Fixes:
|
||||||
* Symbols: added ‘location’ icon (map-pin)
|
* Symbols: added ‘location’ icon (map-pin)
|
||||||
* Blocks: added visual “map-pin” icon to indicate local method blocks
|
* Blocks: added visual “map-pin” icon to indicate local method blocks
|
||||||
|
|
||||||
|
170919
|
||||||
|
------
|
||||||
|
* BYOB: added “inherited” option to inheritable method templates’ context menu in the palette
|
||||||
|
|
||||||
|
|
||||||
v4.1 Features:
|
v4.1 Features:
|
||||||
* polymorphic sprite-local custom blocks
|
* polymorphic sprite-local custom blocks
|
||||||
|
|
Ładowanie…
Reference in New Issue