Skip to content
This repository has been archived by the owner on Sep 3, 2019. It is now read-only.

Commit

Permalink
Prevent deleting or editing list items in player mode
Browse files Browse the repository at this point in the history
  • Loading branch information
nathan committed Jun 30, 2014
1 parent 6deda07 commit 78557f0
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 2 deletions.
1 change: 1 addition & 0 deletions src/Scratch.as
Original file line number Diff line number Diff line change
Expand Up @@ -563,6 +563,7 @@ public class Scratch extends Sprite {
hide(tabsPart);
setTab(null); // hides scripts, images, and sounds
}
stagePane.updateListWatchers();
show(stagePart); // put stage in front
fixLayout();
stagePart.refresh();
Expand Down
9 changes: 9 additions & 0 deletions src/scratch/ScratchStage.as
Original file line number Diff line number Diff line change
Expand Up @@ -653,6 +653,15 @@ public class ScratchStage extends ScratchObj {
if (userAgent) info.userAgent = userAgent;
}

public function updateListWatchers():void {
for (var i:int = 0; i < numChildren; i++) {
var c:DisplayObject = getChildAt(i);
if (c is ListWatcher) {
ListWatcher(c).updateContents();
}
}
}

public function scriptCount():int {
var scriptCount:int;
for each (var obj:ScratchObj in allObjects()) {
Expand Down
4 changes: 2 additions & 2 deletions src/watchers/ListCell.as
Original file line number Diff line number Diff line change
Expand Up @@ -88,10 +88,10 @@ public class ListCell extends Sprite {
}

private function focusChange(e:FocusEvent):void {
var hasFocus:Boolean = e.type == FocusEvent.FOCUS_IN;
var hasFocus:Boolean = e.type == FocusEvent.FOCUS_IN && tf.type == 'input';
frame.setColor(hasFocus ? focusedColor : normalColor);
tf.textColor = hasFocus ? 0 : 0xFFFFFF;
setTimeout(hasFocus && tf.type == 'input' ? addDeleteButton : removeDeleteButton, 1);
setTimeout(hasFocus ? addDeleteButton : removeDeleteButton, 1);
}

private function removeDeleteButton():void {
Expand Down

0 comments on commit 78557f0

Please sign in to comment.