mirror of
https://github.com/google/blockly.git
synced 2026-03-10 07:10:11 +01:00
Add click events to non-closing flyout blocks. Issue #337.
This commit is contained in:
@@ -28,6 +28,7 @@ goog.provide('Blockly.Flyout');
|
||||
|
||||
goog.require('Blockly.Block');
|
||||
goog.require('Blockly.Comment');
|
||||
goog.require('Blockly.Events.Ui');
|
||||
goog.require('Blockly.WorkspaceSvg');
|
||||
goog.require('goog.dom');
|
||||
goog.require('goog.events');
|
||||
@@ -436,16 +437,18 @@ Blockly.Flyout.prototype.show = function(xmlList) {
|
||||
if (this.autoClose) {
|
||||
this.listeners_.push(Blockly.bindEvent_(root, 'mousedown', null,
|
||||
this.createBlockFunc_(block)));
|
||||
this.listeners_.push(Blockly.bindEvent_(rect, 'mousedown', null,
|
||||
this.createBlockFunc_(block)));
|
||||
} else {
|
||||
this.listeners_.push(Blockly.bindEvent_(root, 'mousedown', null,
|
||||
this.blockMouseDown_(block)));
|
||||
this.listeners_.push(Blockly.bindEvent_(rect, 'mousedown', null,
|
||||
this.blockMouseDown_(block)));
|
||||
}
|
||||
this.listeners_.push(Blockly.bindEvent_(root, 'mouseover', block,
|
||||
block.addSelect));
|
||||
this.listeners_.push(Blockly.bindEvent_(root, 'mouseout', block,
|
||||
block.removeSelect));
|
||||
this.listeners_.push(Blockly.bindEvent_(rect, 'mousedown', null,
|
||||
this.createBlockFunc_(block)));
|
||||
this.listeners_.push(Blockly.bindEvent_(rect, 'mouseover', block,
|
||||
block.addSelect));
|
||||
this.listeners_.push(Blockly.bindEvent_(rect, 'mouseout', block,
|
||||
@@ -544,7 +547,7 @@ Blockly.Flyout.prototype.blockMouseDown_ = function(block) {
|
||||
Blockly.Flyout.startBlock_ = block;
|
||||
Blockly.Flyout.startFlyout_ = flyout;
|
||||
Blockly.Flyout.onMouseUpWrapper_ = Blockly.bindEvent_(document,
|
||||
'mouseup', this, Blockly.terminateDrag_);
|
||||
'mouseup', this, flyout.onMouseUp_);
|
||||
Blockly.Flyout.onMouseMoveBlockWrapper_ = Blockly.bindEvent_(document,
|
||||
'mousemove', this, flyout.onMouseMoveBlock_);
|
||||
}
|
||||
@@ -574,6 +577,23 @@ Blockly.Flyout.prototype.onMouseDown_ = function(e) {
|
||||
e.stopPropagation();
|
||||
};
|
||||
|
||||
/**
|
||||
* Handle a mouse-up anywhere in the SVG pane. Is only registered when a
|
||||
* block is clicked. We can't use mouseUp on the block since a fast-moving
|
||||
* cursor can briefly escape the block before it catches up.
|
||||
* @param {!Event} e Mouse up event.
|
||||
* @private
|
||||
*/
|
||||
Blockly.Flyout.prototype.onMouseUp_ = function(e) {
|
||||
if (Blockly.dragMode_ != Blockly.DRAG_FREE &&
|
||||
!Blockly.WidgetDiv.isVisible()) {
|
||||
Blockly.Events.fire(
|
||||
new Blockly.Events.Ui(Blockly.Flyout.startBlock_, 'click',
|
||||
undefined, undefined));
|
||||
}
|
||||
Blockly.terminateDrag_();
|
||||
};
|
||||
|
||||
/**
|
||||
* Handle a mouse-move to vertically drag the flyout.
|
||||
* @param {!Event} e Mouse move event.
|
||||
|
||||
Reference in New Issue
Block a user