Rename checkAndBind and update comments.

This commit is contained in:
Rachel Fenichel
2021-02-23 10:20:13 -08:00
parent ed358c8454
commit f20b06faa8
4 changed files with 18 additions and 17 deletions

View File

@@ -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;

View File

@@ -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.<!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.

View File

@@ -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.

View File

@@ -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_);
}