mirror of
https://github.com/scratchfoundation/scratch-flash.git
synced 2024-12-04 21:21:06 -05:00
Merge branch 'orphaned-comment'
Conflicts: src/scratch/ScratchRuntime.as
This commit is contained in:
commit
73ce84c772
2 changed files with 39 additions and 6 deletions
|
@ -43,7 +43,7 @@ import flash.display.*;
|
|||
import translation.Translator;
|
||||
import util.*;
|
||||
import uiwidgets.*;
|
||||
import scratch.ScratchStage;
|
||||
import scratch.*;
|
||||
|
||||
public class Block extends Sprite {
|
||||
|
||||
|
@ -824,6 +824,22 @@ public class Block extends Sprite {
|
|||
Scratch.app.runtime.checkForGraphicEffects();
|
||||
}
|
||||
|
||||
public function attachedCommentsIn(scriptsPane:ScriptsPane):Array {
|
||||
var allBlocks:Array = [];
|
||||
allBlocksDo(function (b:Block):void {
|
||||
allBlocks.push(b);
|
||||
});
|
||||
var result:Array = []
|
||||
if (!scriptsPane) return result;
|
||||
for (var i:int = 0; i < scriptsPane.numChildren; i++) {
|
||||
var c:ScratchComment = scriptsPane.getChildAt(i) as ScratchComment;
|
||||
if (c && c.blockRef && allBlocks.indexOf(c.blockRef) != -1) {
|
||||
result.push(c);
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
public function addComment():void {
|
||||
var scriptsPane:ScriptsPane = topBlock().parent as ScriptsPane;
|
||||
if (scriptsPane) scriptsPane.addComment(this);
|
||||
|
|
|
@ -989,6 +989,16 @@ public class ScratchRuntime {
|
|||
public function clearLastDelete():void { lastDelete = null }
|
||||
|
||||
public function recordForUndelete(obj:*, x:int, y:int, index:int, owner:* = null):void {
|
||||
if (obj is Block) {
|
||||
var comments:Array = (obj as Block).attachedCommentsIn(app.scriptsPane);
|
||||
if (comments.length) {
|
||||
for each (var c:ScratchComment in comments) {
|
||||
c.parent.removeChild(c);
|
||||
}
|
||||
app.scriptsPane.fixCommentLayout();
|
||||
obj = [obj, comments];
|
||||
}
|
||||
}
|
||||
lastDelete = [obj, x, y, index, owner];
|
||||
}
|
||||
|
||||
|
@ -1014,13 +1024,20 @@ public class ScratchRuntime {
|
|||
app.addNewSprite(obj);
|
||||
obj.setScratchXY(x, y);
|
||||
app.selectSprite(obj);
|
||||
} else if ((obj is Block) || (obj is ScratchComment)) {
|
||||
} else if ((obj is Array) || (obj is Block) || (obj is ScratchComment)) {
|
||||
app.selectSprite(prevOwner);
|
||||
app.setTab('scripts');
|
||||
obj.x = app.scriptsPane.padding;
|
||||
obj.y = app.scriptsPane.padding;
|
||||
if (obj is Block) obj.cacheAsBitmap = true;
|
||||
app.scriptsPane.addChild(obj);
|
||||
var b:DisplayObject = obj is Array ? obj[0] : obj;
|
||||
b.x = app.scriptsPane.padding;
|
||||
b.y = app.scriptsPane.padding;
|
||||
if (b is Block) b.cacheAsBitmap = true;
|
||||
app.scriptsPane.addChild(b);
|
||||
if (obj is Array) {
|
||||
for each (var c:ScratchComment in obj[1]) {
|
||||
app.scriptsPane.addChild(c);
|
||||
}
|
||||
app.scriptsPane.fixCommentLayout();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue