Skip to content

Commit 925bc58

Browse files
walterbenderWalter Bender
andauthored
Paste regression fix (#4354)
* if paste div is open, paste contents when Enter is typed * add check button and remove textMsg --------- Co-authored-by: Walter Bender <[email protected]>
1 parent f5f0e12 commit 925bc58

File tree

2 files changed

+19
-8
lines changed

2 files changed

+19
-8
lines changed

js/activity.js

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2876,6 +2876,11 @@ class Activity {
28762876
if (this.searchWidget.style.visibility === 'visible') {
28772877
return;
28782878
}
2879+
if (docById("paste").style.visibility === "visible") {
2880+
this.pasted();
2881+
docById("paste").style.visibility = "hidden";
2882+
return;
2883+
}
28792884
this.textMsg("Enter " + _("Play"));
28802885
let stopbt = document.getElementById("stop");
28812886
if (stopbt) {
@@ -2888,7 +2893,7 @@ class Activity {
28882893
this.logo.doStopTurtles();
28892894
break;
28902895
case 86: // 'V'
2891-
this.textMsg("Alt-V " + _("Paste"));
2896+
// this.textMsg("Alt-V " + _("Paste"));
28922897
this.blocks.pasteStack();
28932898
break;
28942899
case 72: // 'H' save block help
@@ -2910,7 +2915,7 @@ class Activity {
29102915
} else if (event.ctrlKey) {
29112916
switch (event.keyCode) {
29122917
case V:
2913-
this.textMsg("Ctl-V " + _("Paste"));
2918+
// this.textMsg("Ctl-V " + _("Paste"));
29142919
this.pasteBox.createBox(this.turtleBlocksScale, 200, 200);
29152920
this.pasteBox.show();
29162921
docById("paste").style.left =

js/pastebox.js

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,18 +10,18 @@
1010
// Foundation, 51 Franklin Street, Suite 500 Boston, MA 02110-1335 USA
1111

1212
const PASTEBOX =
13-
'<svg xmlns="http://www.w3.org/2000/svg" version="1.1" width="280" height="55"> <rect width="280" height="55" x="0" y="-3.5762787e-06" style="fill:#f0f0f0;fill-opacity:1;fill-rule:nonzero;stroke:none" /> <g transform="translate(225,0)" style="fill:#000000;display:block"> <path d="m 27.557,5.053 c -12.43,0 -22.5,10.076 -22.5,22.497 0,12.432 10.07,22.503 22.5,22.503 12.431,0 22.5,-10.071 22.5,-22.503 0,-12.421 -10.07,-22.497 -22.5,-22.497 z m 10.199,28.159 c 1.254,1.256 1.257,3.291 0,4.545 -0.628,0.629 -1.451,0.943 -2.274,0.943 -0.822,0 -1.644,-0.314 -2.27,-0.94 l -5.76,-5.761 -5.76,5.761 c -0.627,0.626 -1.449,0.94 -2.271,0.94 -0.823,0 -1.647,-0.314 -2.275,-0.943 -1.254,-1.254 -1.254,-3.289 0.004,-4.545 l 5.758,-5.758 -5.758,-5.758 c -1.258,-1.254 -1.258,-3.292 -0.004,-4.546 1.255,-1.254 3.292,-1.259 4.546,0 l 5.76,5.759 5.76,-5.759 c 1.252,-1.259 3.288,-1.254 4.544,0 1.257,1.254 1.254,3.292 0,4.546 l -5.758,5.758 5.758,5.758 z" style="fill:#000000;display:inline" /> </g></svg>';
13+
'<?xml version="1.0" encoding="UTF-8" standalone="no"?><svg version="1.1" width="300" height="55" id="svg1" xmlns="http://www.w3.org/2000/svg" xmlns:svg="http://www.w3.org/2000/svg"> <defs id="defs1" /> <rect width="300" height="55" x="0" y="0" style="fill:#f0f0f0;fill-opacity:1;fill-rule:nonzero;stroke:none;stroke-width:1.0351" id="rect1" /> <g transform="translate(244.943,-0.05299642)" style="display:block;fill:#000000" id="g1"> <path d="m 27.557,5.053 c -12.43,0 -22.5,10.076 -22.5,22.497 0,12.432 10.07,22.503 22.5,22.503 12.431,0 22.5,-10.071 22.5,-22.503 0,-12.421 -10.07,-22.497 -22.5,-22.497 z m 10.199,28.159 c 1.254,1.256 1.257,3.291 0,4.545 -0.628,0.629 -1.451,0.943 -2.274,0.943 -0.822,0 -1.644,-0.314 -2.27,-0.94 l -5.76,-5.761 -5.76,5.761 c -0.627,0.626 -1.449,0.94 -2.271,0.94 -0.823,0 -1.647,-0.314 -2.275,-0.943 -1.254,-1.254 -1.254,-3.289 0.004,-4.545 l 5.758,-5.758 -5.758,-5.758 c -1.258,-1.254 -1.258,-3.292 -0.004,-4.546 1.255,-1.254 3.292,-1.259 4.546,0 l 5.76,5.759 5.76,-5.759 c 1.252,-1.259 3.288,-1.254 4.544,0 1.257,1.254 1.254,3.292 0,4.546 l -5.758,5.758 z" style="display:inline;fill:#000000" id="path1" /> </g> <g id="g4" transform="translate(18,-0.05299642)"> <g transform="translate(176.943)" style="display:block;fill:#008000" id="g2"> <path d="m 27.557,5.053 c -12.43,0 -22.5,10.076 -22.5,22.497 0,12.432 10.07,22.503 22.5,22.503 12.431,0 22.5,-10.071 22.5,-22.503 0,-12.421 -10.07,-22.497 -22.5,-22.497 z" style="display:inline;fill:#008000" id="path1-3" /> </g> <path id="path3" style="fill:#ffffff;stroke:#ffffff;stroke-width:6;stroke-linecap:round;stroke-linejoin:round;stroke-dasharray:none;stroke-opacity:1" d="m 216.1272,19.380148 -16.33945,16.345703 z m -23.25273,8.640234 6.91328,7.705469 z" /> </g></svg>'
1414

1515
// A pop up for pasting from the browser clipboard
1616

1717
/* global docById, createjs */
1818

1919
/*
20-
Global locations
20+
Global locations
2121
js/utils/utils.js
22-
_
22+
_
2323
js/activity.js
24-
createjs
24+
createjs
2525
*/
2626

2727
/* exported PasteBox */
@@ -127,9 +127,15 @@ class PasteBox {
127127

128128
const x = event.stageX / this._scale - this._container.x;
129129
const y = event.stageY / this._scale - this._container.y;
130-
if (x > 125 && y < 55) {
130+
console.log(x,y);
131+
132+
if (x > 200 && x < 250 && y < 55) {
133+
this.activity.pasted();
131134
this.hide();
132135
}
136+
if (x > 250 && y < 55) {
137+
this.hide();
138+
}
133139
});
134140
}
135141

@@ -151,4 +157,4 @@ class PasteBox {
151157
}
152158
if (typeof module !== "undefined" && module.exports) {
153159
module.exports = PasteBox;
154-
}
160+
}

0 commit comments

Comments
 (0)