From f5c330f4042f4148399e696a9bd30fa5b7b27697 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jens=20M=C3=B6nig?= Date: Sun, 23 Jan 2022 11:25:04 +0100 Subject: [PATCH] support dragging blocks out from table views --- HISTORY.md | 1 + snap.html | 2 +- src/tables.js | 23 ++++++++++++++++++++++- 3 files changed, 24 insertions(+), 2 deletions(-) diff --git a/HISTORY.md b/HISTORY.md index b55a2d71..df21ce75 100755 --- a/HISTORY.md +++ b/HISTORY.md @@ -12,6 +12,7 @@ ### 2022-01-23 * morphic: added Node >> childThatIsA +* tables: support dragging blocks out from table views ### 2022-01-22 * blocks: support dragging blocks out from result bubbles diff --git a/snap.html b/snap.html index affcda33..d5350b2b 100755 --- a/snap.html +++ b/snap.html @@ -24,7 +24,7 @@ - + diff --git a/src/tables.js b/src/tables.js index ba89408a..186c573c 100644 --- a/src/tables.js +++ b/src/tables.js @@ -72,7 +72,7 @@ ListWatcherMorph, BoxMorph, Variable, isSnapObject, useBlurredShadows*/ /*jshint esversion: 6*/ -modules.tables = '2021-July-05'; +modules.tables = '2022-January-23'; var Table; var TableCellMorph; @@ -343,6 +343,7 @@ TableCellMorph.prototype.render = function (ctx) { x, y; + this.isDraggable = this.data instanceof Context; ctx.fillStyle = background; if (this.shouldBeList()) { BoxMorph.prototype.outlinePath.call( @@ -475,6 +476,26 @@ TableCellMorph.prototype.mouseLeave = function () { } }; +TableCellMorph.prototype.selectForEdit = function () { + var script = this.data.toBlock(), + prepare = script.prepareToBeGrabbed, + ide = this.parentThatIsA(IDE_Morph) || + this.world().childThatIsA(IDE_Morph); + + script.prepareToBeGrabbed = function (hand) { + prepare.call(this, hand); + hand.grabOrigin = { + origin: ide.palette, + position: ide.palette.center() + }; + this.prepareToBeGrabbed = prepare; + }; + + if (ide.isAppMode) {return; } + script.setPosition(this.position()); + return script; +}; + // TableMorph ////////////////////////////////////////////////////////// // TableMorph inherits from FrameMorph: