mirror of
https://github.com/google/blockly.git
synced 2026-01-10 02:17:09 +01:00
Ignore mouseup at end of drag with isDragging (#416)
This includes both block drags and workspace scrolls and fixes #404. I used isDragging rather than checking the origin of click so that it can easily be extended to the case where the flyout is scrolled by dragging a block, a la LLK/scratch-blocks#206.
This commit is contained in:
committed by
Neil Fraser
parent
ff90218c07
commit
2dcb6cb68b
@@ -433,7 +433,7 @@ Blockly.Field.prototype.onMouseUp_ = function(e) {
|
||||
} else if (Blockly.isRightButton(e)) {
|
||||
// Right-click.
|
||||
return;
|
||||
} else if (Blockly.dragMode_ == Blockly.DRAG_FREE) {
|
||||
} else if (this.sourceBlock_.workspace.isDragging()) {
|
||||
// Drag operation is concluding. Don't open the editor.
|
||||
return;
|
||||
} else if (this.sourceBlock_.isEditable()) {
|
||||
|
||||
@@ -761,8 +761,7 @@ Blockly.Flyout.prototype.onMouseDown_ = function(e) {
|
||||
* @private
|
||||
*/
|
||||
Blockly.Flyout.prototype.onMouseUp_ = function(e) {
|
||||
if (Blockly.dragMode_ != Blockly.DRAG_FREE &&
|
||||
!Blockly.WidgetDiv.isVisible()) {
|
||||
if (!this.workspace_.isDragging() && !Blockly.WidgetDiv.isVisible()) {
|
||||
Blockly.Events.fire(
|
||||
new Blockly.Events.Ui(Blockly.Flyout.startBlock_, 'click',
|
||||
undefined, undefined));
|
||||
|
||||
@@ -124,7 +124,7 @@ Blockly.Icon.prototype.isVisible = function() {
|
||||
* @private
|
||||
*/
|
||||
Blockly.Icon.prototype.iconClick_ = function(e) {
|
||||
if (Blockly.dragMode_ == Blockly.DRAG_FREE) {
|
||||
if (this.block_.workspace.isDragging()) {
|
||||
// Drag operation is concluding. Don't open the editor.
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -710,6 +710,14 @@ Blockly.WorkspaceSvg.prototype.moveDrag = function(e) {
|
||||
return goog.math.Coordinate.sum(this.dragDeltaXY_, point);
|
||||
};
|
||||
|
||||
/**
|
||||
* Is the user currently dragging a block or scrolling the workspace?
|
||||
* @return {boolean} True if currently dragging or scrolling
|
||||
*/
|
||||
Blockly.WorkspaceSvg.prototype.isDragging = function() {
|
||||
return Blockly.dragMode_ == Blockly.DRAG_FREE || this.isScrolling;
|
||||
};
|
||||
|
||||
/**
|
||||
* Handle a mouse-wheel on SVG drawing surface.
|
||||
* @param {!Event} e Mouse wheel event.
|
||||
|
||||
Reference in New Issue
Block a user