diff --git a/src/botPage/view/blockly/customBlockly.js b/src/botPage/view/blockly/customBlockly.js index a2da174a43..2080b02199 100644 --- a/src/botPage/view/blockly/customBlockly.js +++ b/src/botPage/view/blockly/customBlockly.js @@ -405,6 +405,40 @@ Blockly.Constants.Loops.CUSTOM_CONTEXT_MENU_CREATE_VARIABLES_GET_MIXIN.customCon }; /** + * Update this gesture to record whether a block is being dragged from the + * flyout. + * This function should be called on a mouse/touch move event the first time the + * drag radius is exceeded. It should be called no more than once per gesture. + * If a block should be dragged from the flyout this function creates the new + * block on the main workspace and updates targetBlock_ and startWorkspace_. + * @return {boolean} True if a block is being dragged from the flyout. + * @private + */ +Blockly.Gesture.prototype.updateIsDraggingFromFlyout_ = function() { + // Disabled blocks may not be dragged from the flyout. + if (this.targetBlock_.disabled) { + return false; + } + + if (!this.flyout_.isScrollable() || this.flyout_.isDragTowardWorkspace(this.currentDragDeltaXY_)) { + GTM.pushDataLayer({ event: 'Block Event', blockEvent: 'Drag n Drop' }); + this.startWorkspace_ = this.flyout_.targetWorkspace_; + this.startWorkspace_.updateScreenCalculationsIfScrolled(); + // Start the event group now, so that the same event group is used for block + // creation and block dragging. + if (!Blockly.Events.getGroup()) { + Blockly.Events.setGroup(true); + } + // The start block is no longer relevant, because this is a drag. + this.startBlock_ = null; + this.targetBlock_ = this.flyout_.createBlock(this.targetBlock_); + this.targetBlock_.select(); + return true; + } + return false; +}; + +/* * Return the parent block or null if this block is at the top level. * @return {Blockly.Block} The block that holds the current block. */