Merge pull request #2696 from robertf224/rf/block-menu-add-comment

Add "add comment" option to the block context menu
pull/95/head
Jens Mönig 2020-09-25 15:38:52 +02:00 zatwierdzone przez GitHub
commit cce7f879ad
Nie znaleziono w bazie danych klucza dla tego podpisu
ID klucza GPG: 4AEE18F83AFDEB23
1 zmienionych plików z 29 dodań i 0 usunięć

Wyświetl plik

@ -3024,6 +3024,35 @@ BlockMorph.prototype.userMenu = function () {
"delete",
'userDestroy'
);
if (isNil(this.comment)) {
menu.addItem(
"add comment",
() => {
var comment = new CommentMorph();
this.comment = comment;
comment.block = this;
comment.layoutChanged();
// Simulate drag/drop for better undo/redo behavior
var scripts = this.parentThatIsA(ScriptsMorph),
ide = this.parentThatIsA(IDE_Morph),
blockEditor = this.parentThatIsA(BlockEditorMorph);
if (!ide && blockEditor) {
ide = blockEditor.target.parentThatIsA(IDE_Morph);
}
if (ide) {
world.hand.grabOrigin = {
origin: ide.palette,
position: ide.palette.center()
};
}
scripts.clearDropInfo();
scripts.lastDropTarget = { element: this };
scripts.lastDroppedBlock = comment;
scripts.recordDrop(world.hand.grabOrigin);
}
);
}
menu.addItem(
"script pic...",
() => {