mirror of
https://github.com/google/blockly.git
synced 2026-01-09 18:10:08 +01:00
@@ -291,6 +291,7 @@ Blockly.BlockDragger.prototype.maybeDeleteBlock_ = function() {
|
||||
// Fire a move event, so we know where to go back to for an undo.
|
||||
this.fireMoveEvent_();
|
||||
this.draggingBlock_.dispose(false, true);
|
||||
Blockly.draggingConnections = [];
|
||||
} else if (trashcan) {
|
||||
// Make sure the trash can is closed.
|
||||
trashcan.close();
|
||||
|
||||
@@ -943,7 +943,8 @@ Blockly.BlockSvg.prototype.dispose = function(healStack, animate) {
|
||||
// The block has already been deleted.
|
||||
return;
|
||||
}
|
||||
Blockly.Tooltip.hide();
|
||||
Blockly.Tooltip.dispose();
|
||||
Blockly.Tooltip.unbindMouseEvents(this.pathObject.svgPath);
|
||||
Blockly.utils.dom.startTextWidthCache();
|
||||
// Save the block's workspace temporarily so we can resize the
|
||||
// contents once the block is disposed.
|
||||
|
||||
@@ -394,6 +394,7 @@ Blockly.Field.prototype.toXml = function(fieldElement) {
|
||||
Blockly.Field.prototype.dispose = function() {
|
||||
Blockly.DropDownDiv.hideIfOwner(this);
|
||||
Blockly.WidgetDiv.hideIfOwner(this);
|
||||
Blockly.Tooltip.unbindMouseEvents(this.getClickTarget_());
|
||||
|
||||
if (this.mouseDownWrapper_) {
|
||||
Blockly.unbindEvent_(this.mouseDownWrapper_);
|
||||
|
||||
@@ -548,6 +548,7 @@ Blockly.Flyout.prototype.clearOldBlocks_ = function() {
|
||||
for (var j = 0; j < this.mats_.length; j++) {
|
||||
var rect = this.mats_[j];
|
||||
if (rect) {
|
||||
Blockly.Tooltip.unbindMouseEvents(rect);
|
||||
Blockly.utils.dom.removeNode(rect);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -129,9 +129,9 @@ Blockly.Tooltip.createDom = function() {
|
||||
* @param {!Element} element SVG element onto which tooltip is to be bound.
|
||||
*/
|
||||
Blockly.Tooltip.bindMouseEvents = function(element) {
|
||||
Blockly.bindEvent_(element, 'mouseover', null,
|
||||
element.mouseOverWrapper_ = Blockly.bindEvent_(element, 'mouseover', null,
|
||||
Blockly.Tooltip.onMouseOver_);
|
||||
Blockly.bindEvent_(element, 'mouseout', null,
|
||||
element.mouseOutWrapper_ = Blockly.bindEvent_(element, 'mouseout', null,
|
||||
Blockly.Tooltip.onMouseOut_);
|
||||
|
||||
// Don't use bindEvent_ for mousemove since that would create a
|
||||
@@ -140,6 +140,19 @@ Blockly.Tooltip.bindMouseEvents = function(element) {
|
||||
element.addEventListener('mousemove', Blockly.Tooltip.onMouseMove_, false);
|
||||
};
|
||||
|
||||
/**
|
||||
* Unbinds tooltip mouse events from the SVG element.
|
||||
* @param {!Element} element SVG element onto which tooltip is bound.
|
||||
*/
|
||||
Blockly.Tooltip.unbindMouseEvents = function(element) {
|
||||
if (!element) {
|
||||
return;
|
||||
}
|
||||
Blockly.unbindEvent_(element.mouseOverWrapper_);
|
||||
Blockly.unbindEvent_(element.mouseOutWrapper_);
|
||||
element.removeEventListener('mousemove', Blockly.Tooltip.onMouseMove_);
|
||||
};
|
||||
|
||||
/**
|
||||
* Hide the tooltip if the mouse is over a different object.
|
||||
* Initialize the tooltip to potentially appear for this object.
|
||||
@@ -223,6 +236,16 @@ Blockly.Tooltip.onMouseMove_ = function(e) {
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Dispose of the tooltip.
|
||||
* @package
|
||||
*/
|
||||
Blockly.Tooltip.dispose = function() {
|
||||
Blockly.Tooltip.element_ = null;
|
||||
Blockly.Tooltip.poisonedElement_ = null;
|
||||
Blockly.Tooltip.hide();
|
||||
};
|
||||
|
||||
/**
|
||||
* Hide the tooltip.
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user