support dragging blocks out from variable watchers

snap7
Jens Mönig 2022-01-22 00:46:23 +01:00
rodzic 9ef62d98bb
commit 27710d2f79
2 zmienionych plików z 25 dodań i 2 usunięć

Wyświetl plik

@ -3,7 +3,7 @@
## in development:
* **New Features:**
* support dragging blocks out from result bubbles and speech balloons
* support dragging blocks out from result bubbles, speech balloons and variable watchers
* **Notable Changes:**
* **Notable Fixes:**
* fixed layout for scrolling custom categories, thanks, Eckart, for the bug report!
@ -13,6 +13,7 @@
### 2022-01-22
* blocks: support dragging blocks out from result bubbles
* objects: support dragging blocks out from speech balloons
* objects: support dragging blocks out from variable watchers
### 2022-01-21
* new dev version

Wyświetl plik

@ -10052,7 +10052,7 @@ SpriteBubbleMorph.prototype.dataAsMorph = function (data) {
contents.bounds.setHeight(img.height);
contents.cachedImage = img;
// support blocks to be dragged out of result bubbles:
// support blocks to be dragged out of speech balloons:
contents.isDraggable = true;
contents.selectForEdit = function () {
@ -11383,6 +11383,7 @@ CellMorph.prototype.createContents = function () {
// re-build my contents
var txt,
img,
myself = this,
fontSize = SyntaxElementMorph.prototype.fontSize,
isSameList = this.contentsMorph instanceof ListWatcherMorph
&& (this.contentsMorph.list === this.contents),
@ -11451,6 +11452,27 @@ CellMorph.prototype.createContents = function () {
this.contentsMorph.bounds.setWidth(img.width);
this.contentsMorph.bounds.setHeight(img.height);
this.contentsMorph.cachedImage = img;
// support blocks to be dragged out of watchers:
this.contentsMorph.isDraggable = true;
this.contentsMorph.selectForEdit = function () {
var script = myself.contents.toBlock(),
prepare = script.prepareToBeGrabbed,
ide = this.parentThatIsA(IDE_Morph);
script.prepareToBeGrabbed = function (hand) {
prepare.call(this, hand);
hand.grabOrigin = {
origin: ide.palette,
position: ide.palette.center()
};
this.prepareToBeGrabbed = prepare;
};
script.setPosition(this.position());
return script;
};
} else if (this.contents instanceof Costume) {
img = this.contents.thumbnail(new Point(40, 40));
this.contentsMorph = new Morph();