diff --git a/core/blockly.js b/core/blockly.js index 0123d7626..7dd8824fd 100644 --- a/core/blockly.js +++ b/core/blockly.js @@ -487,4 +487,4 @@ Blockly.setParentContainer = function(container) { /** Aliases. */ Blockly.bindEvent_ = Blockly.browserEvents.bind; Blockly.unbindEvent_ = Blockly.browserEvents.unbind; -Blockly.bindEventWithChecks_ = Blockly.browserEvents.checkAndBind; +Blockly.bindEventWithChecks_ = Blockly.browserEvents.bindFilterable; diff --git a/core/browser_events.js b/core/browser_events.js index 9d98b54c4..d3bafdefa 100644 --- a/core/browser_events.js +++ b/core/browser_events.js @@ -17,16 +17,17 @@ goog.require('Blockly.Touch'); /** * Blockly opaque event data used to unbind events when using - * `Blockly.browserEvents.bindEvent_` and - * `Blockly.browserEvents.bindEventWithChecks_`. + * `Blockly.browserEvents.bind` and + * `Blockly.browserEvents.bindFilterable`. * @typedef {!Array.} */ Blockly.browserEvents.Data; /** - * Bind an event to a function call. When calling the function, verifies that - * it belongs to the touch stream that is currently being processed, and splits - * multitouch events into multiple events as needed. + * Bind an event handler that can be ignored if it is not part of the active + * touch stream. + * Use this for events that either start or continue a multi-part gesture (e.g. + * mousedown or mousemove, which may be part of a drag or click). * @param {!EventTarget} node Node upon which to listen. * @param {string} name Event name to listen to (e.g. 'mousedown'). * @param {Object} thisObject The value of 'this' in the function. @@ -42,7 +43,7 @@ Blockly.browserEvents.Data; * unbindEvent_. * @public */ -Blockly.browserEvents.checkAndBind = function( +Blockly.browserEvents.bindFilterable = function( node, name, thisObject, func, opt_noCaptureIdentifier, opt_noPreventDefault) { var handled = false; @@ -98,10 +99,10 @@ Blockly.browserEvents.checkAndBind = function( /** - * Bind an event to a function call. Handles multitouch events by using the - * coordinates of the first changed touch, and doesn't do any safety checks for - * simultaneous event processing. In most cases prefer is to use - * `Blockly.bindEventWithChecks_`. + * Bind an event handler that should be called regardless of whether it is part + * of the active touch stream. + * Use this for events that are not part of a multi-part gesture (e.g. + * mouseover for tooltips). * @param {!EventTarget} node Node upon which to listen. * @param {string} name Event name to listen to (e.g. 'mousedown'). * @param {Object} thisObject The value of 'this' in the function. diff --git a/core/bubble.js b/core/bubble.js index 5ee397c5b..25264feec 100644 --- a/core/bubble.js +++ b/core/bubble.js @@ -300,10 +300,10 @@ Blockly.Bubble.prototype.createDom_ = function(content, hasResize) { } if (!this.workspace_.options.readOnly) { - this.onMouseDownBubbleWrapper_ = Blockly.browserEvents.checkAndBind( + this.onMouseDownBubbleWrapper_ = Blockly.browserEvents.bindFilterable( this.bubbleBack_, 'mousedown', this, this.bubbleMouseDown_); if (this.resizeGroup_) { - this.onMouseDownResizeWrapper_ = Blockly.browserEvents.checkAndBind( + this.onMouseDownResizeWrapper_ = Blockly.browserEvents.bindFilterable( this.resizeGroup_, 'mousedown', this, this.resizeMouseDown_); } } @@ -388,9 +388,9 @@ Blockly.Bubble.prototype.resizeMouseDown_ = function(e) { new Blockly.utils.Coordinate( this.workspace_.RTL ? -this.width_ : this.width_, this.height_)); - Blockly.Bubble.onMouseUpWrapper_ = Blockly.browserEvents.checkAndBind( + Blockly.Bubble.onMouseUpWrapper_ = Blockly.browserEvents.bindFilterable( document, 'mouseup', this, Blockly.Bubble.bubbleMouseUp_); - Blockly.Bubble.onMouseMoveWrapper_ = Blockly.browserEvents.checkAndBind( + Blockly.Bubble.onMouseMoveWrapper_ = Blockly.browserEvents.bindFilterable( document, 'mousemove', this, this.resizeMouseMove_); Blockly.hideChaff(); // This event has been handled. No need to bubble up to the document. diff --git a/core/workspace_svg.js b/core/workspace_svg.js index 9d65802da..cddfa2f08 100644 --- a/core/workspace_svg.js +++ b/core/workspace_svg.js @@ -809,9 +809,9 @@ Blockly.WorkspaceSvg.prototype.createDom = function(opt_backgroundClass) { {'class': 'blocklyBubbleCanvas'}, this.svgGroup_); if (!this.isFlyout) { - Blockly.browserEvents.checkAndBind( + Blockly.browserEvents.bindFilterable( this.svgGroup_, 'mousedown', this, this.onMouseDown_, false, true); - Blockly.browserEvents.checkAndBind( + Blockly.browserEvents.bindFilterable( this.svgGroup_, 'wheel', this, this.onMouseWheel_); }