Skip to content

Commit 1be8f5c

Browse files
When dragging a block from the scripts palette to the scripts panel, insertion/wrapping previews will only occur when the mouse is inside the scripts panel.
1 parent a97973c commit 1be8f5c

File tree

1 file changed

+30
-15
lines changed

1 file changed

+30
-15
lines changed

src/uiwidgets/ScriptsPane.as

Lines changed: 30 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -139,11 +139,29 @@ public class ScriptsPane extends ScrollFrameContents {
139139
}
140140

141141
public function updateFeedbackFor(b:Block):void {
142-
nearestTarget = nearestTargetForBlockIn(b, possibleTargets);
143-
if (b.base.canHaveSubstack1() && !b.subStack1) {
144-
var o:Block = null;
145-
if (nearestTarget) {
146-
t = nearestTarget[1];
142+
if (mouseX + x >= 0) {
143+
nearestTarget = nearestTargetForBlockIn(b, possibleTargets);
144+
if (nearestTarget != null) {
145+
updateFeedbackShape();
146+
} else {
147+
hideFeedbackShape();
148+
}
149+
if (b.base.canHaveSubstack1() && !b.subStack1) {
150+
updateHeight();
151+
}
152+
}
153+
else {
154+
nearestTarget = null;
155+
hideFeedbackShape();
156+
}
157+
158+
fixCommentLayout();
159+
160+
function updateHeight(): void {
161+
var h:int = BlockShape.EmptySubstackH;
162+
if (nearestTarget != null) {
163+
var t:* = nearestTarget[1];
164+
var o:Block = null;
147165
switch (nearestTarget[2]) {
148166
case INSERT_NORMAL:
149167
o = t.nextBlock;
@@ -158,17 +176,17 @@ public class ScriptsPane extends ScrollFrameContents {
158176
o = t.subStack2;
159177
break;
160178
}
161-
}
162-
var h:int = BlockShape.EmptySubstackH;
163-
if (o) {
164-
h = o.height;
165-
if (!o.bottomBlock().isTerminal) h -= BlockShape.NotchDepth;
179+
if (o) {
180+
h = o.height;
181+
if (!o.bottomBlock().isTerminal) h -= BlockShape.NotchDepth;
182+
}
166183
}
167184
b.previewSubstack1Height(h);
168185
}
169-
if (nearestTarget != null) {
170-
var localP:Point = globalToLocal(nearestTarget[0]);
186+
187+
function updateFeedbackShape() : void {
171188
var t:* = nearestTarget[1];
189+
var localP:Point = globalToLocal(nearestTarget[0]);
172190
feedbackShape.x = localP.x;
173191
feedbackShape.y = localP.y;
174192
feedbackShape.visible = true;
@@ -181,10 +199,7 @@ public class ScriptsPane extends ScrollFrameContents {
181199
var isInsertion:Boolean = (insertionType != INSERT_ABOVE) && (insertionType != INSERT_WRAP);
182200
feedbackShape.copyFeedbackShapeFrom(b, false, isInsertion, wrapH);
183201
}
184-
} else {
185-
hideFeedbackShape();
186202
}
187-
fixCommentLayout();
188203
}
189204

190205
public function allStacks():Array {

0 commit comments

Comments
 (0)