mirror of
https://github.com/google/blockly.git
synced 2026-01-09 18:10:08 +01:00
Rename Blockly.eventHandling->Blockly.browserEvents and replace all Blockly.EventData annotations
This commit is contained in:
@@ -17,7 +17,7 @@
|
||||
goog.provide('Blockly');
|
||||
|
||||
goog.require('Blockly.constants');
|
||||
goog.require('Blockly.eventHandling');
|
||||
goog.require('Blockly.browserEvents');
|
||||
goog.require('Blockly.Events');
|
||||
goog.require('Blockly.Events.Ui');
|
||||
goog.require('Blockly.Events.UiBase');
|
||||
@@ -485,6 +485,6 @@ Blockly.setParentContainer = function(container) {
|
||||
};
|
||||
|
||||
/** Aliases. */
|
||||
Blockly.bindEvent_ = Blockly.eventHandling.bind;
|
||||
Blockly.unbindEvent_ = Blockly.eventHandling.unbind;
|
||||
Blockly.bindEventWithChecks_ = Blockly.eventHandling.checkAndBind;
|
||||
Blockly.bindEvent_ = Blockly.browserEvents.bind;
|
||||
Blockly.unbindEvent_ = Blockly.browserEvents.unbind;
|
||||
Blockly.bindEventWithChecks_ = Blockly.browserEvents.checkAndBind;
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
|
||||
goog.provide('Blockly.Bubble');
|
||||
|
||||
goog.require('Blockly.eventHandling');
|
||||
goog.require('Blockly.browserEvents');
|
||||
goog.require('Blockly.Scrollbar');
|
||||
goog.require('Blockly.Touch');
|
||||
goog.require('Blockly.utils');
|
||||
@@ -67,14 +67,14 @@ Blockly.Bubble = function(
|
||||
|
||||
/**
|
||||
* Mouse down on bubbleBack_ event data.
|
||||
* @type {?Blockly.eventHandling.Data}
|
||||
* @type {?Blockly.browserEvents.Data}
|
||||
* @private
|
||||
*/
|
||||
this.onMouseDownBubbleWrapper_ = null;
|
||||
|
||||
/**
|
||||
* Mouse down on resizeGroup_ event data.
|
||||
* @type {?Blockly.eventHandling.Data}
|
||||
* @type {?Blockly.browserEvents.Data}
|
||||
* @private
|
||||
*/
|
||||
this.onMouseDownResizeWrapper_ = null;
|
||||
@@ -138,14 +138,14 @@ Blockly.Bubble.ANCHOR_RADIUS = 8;
|
||||
|
||||
/**
|
||||
* Mouse up event data.
|
||||
* @type {?Blockly.eventHandling.Data}
|
||||
* @type {?Blockly.browserEvents.Data}
|
||||
* @private
|
||||
*/
|
||||
Blockly.Bubble.onMouseUpWrapper_ = null;
|
||||
|
||||
/**
|
||||
* Mouse move event data.
|
||||
* @type {?Blockly.eventHandling.Data}
|
||||
* @type {?Blockly.browserEvents.Data}
|
||||
* @private
|
||||
*/
|
||||
Blockly.Bubble.onMouseMoveWrapper_ = null;
|
||||
@@ -156,11 +156,11 @@ Blockly.Bubble.onMouseMoveWrapper_ = null;
|
||||
*/
|
||||
Blockly.Bubble.unbindDragEvents_ = function() {
|
||||
if (Blockly.Bubble.onMouseUpWrapper_) {
|
||||
Blockly.eventHandling.unbind(Blockly.Bubble.onMouseUpWrapper_);
|
||||
Blockly.browserEvents.unbind(Blockly.Bubble.onMouseUpWrapper_);
|
||||
Blockly.Bubble.onMouseUpWrapper_ = null;
|
||||
}
|
||||
if (Blockly.Bubble.onMouseMoveWrapper_) {
|
||||
Blockly.eventHandling.unbind(Blockly.Bubble.onMouseMoveWrapper_);
|
||||
Blockly.browserEvents.unbind(Blockly.Bubble.onMouseMoveWrapper_);
|
||||
Blockly.Bubble.onMouseMoveWrapper_ = null;
|
||||
}
|
||||
};
|
||||
@@ -300,10 +300,10 @@ Blockly.Bubble.prototype.createDom_ = function(content, hasResize) {
|
||||
}
|
||||
|
||||
if (!this.workspace_.options.readOnly) {
|
||||
this.onMouseDownBubbleWrapper_ = Blockly.eventHandling.checkAndBind(
|
||||
this.onMouseDownBubbleWrapper_ = Blockly.browserEvents.checkAndBind(
|
||||
this.bubbleBack_, 'mousedown', this, this.bubbleMouseDown_);
|
||||
if (this.resizeGroup_) {
|
||||
this.onMouseDownResizeWrapper_ = Blockly.eventHandling.checkAndBind(
|
||||
this.onMouseDownResizeWrapper_ = Blockly.browserEvents.checkAndBind(
|
||||
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.eventHandling.checkAndBind(
|
||||
Blockly.Bubble.onMouseUpWrapper_ = Blockly.browserEvents.checkAndBind(
|
||||
document, 'mouseup', this, Blockly.Bubble.bubbleMouseUp_);
|
||||
Blockly.Bubble.onMouseMoveWrapper_ = Blockly.eventHandling.checkAndBind(
|
||||
Blockly.Bubble.onMouseMoveWrapper_ = Blockly.browserEvents.checkAndBind(
|
||||
document, 'mousemove', this, this.resizeMouseMove_);
|
||||
Blockly.hideChaff();
|
||||
// This event has been handled. No need to bubble up to the document.
|
||||
@@ -822,10 +822,10 @@ Blockly.Bubble.prototype.setColour = function(hexColour) {
|
||||
*/
|
||||
Blockly.Bubble.prototype.dispose = function() {
|
||||
if (this.onMouseDownBubbleWrapper_) {
|
||||
Blockly.eventHandling.unbind(this.onMouseDownBubbleWrapper_);
|
||||
Blockly.browserEvents.unbind(this.onMouseDownBubbleWrapper_);
|
||||
}
|
||||
if (this.onMouseDownResizeWrapper_) {
|
||||
Blockly.eventHandling.unbind(this.onMouseDownResizeWrapper_);
|
||||
Blockly.browserEvents.unbind(this.onMouseDownResizeWrapper_);
|
||||
}
|
||||
Blockly.Bubble.unbindDragEvents_();
|
||||
Blockly.utils.dom.removeNode(this.bubbleGroup_);
|
||||
|
||||
@@ -61,28 +61,28 @@ Blockly.Comment = function(block) {
|
||||
|
||||
/**
|
||||
* Mouse up event data.
|
||||
* @type {?Blockly.EventData}
|
||||
* @type {?Blockly.browserEvents.Data}
|
||||
* @private
|
||||
*/
|
||||
this.onMouseUpWrapper_ = null;
|
||||
|
||||
/**
|
||||
* Wheel event data.
|
||||
* @type {?Blockly.EventData}
|
||||
* @type {?Blockly.browserEvents.Data}
|
||||
* @private
|
||||
*/
|
||||
this.onWheelWrapper_ = null;
|
||||
|
||||
/**
|
||||
* Change event data.
|
||||
* @type {?Blockly.EventData}
|
||||
* @type {?Blockly.browserEvents.Data}
|
||||
* @private
|
||||
*/
|
||||
this.onChangeWrapper_ = null;
|
||||
|
||||
/**
|
||||
* Input event data.
|
||||
* @type {?Blockly.EventData}
|
||||
* @type {?Blockly.browserEvents.Data}
|
||||
* @private
|
||||
*/
|
||||
this.onInputWrapper_ = null;
|
||||
|
||||
@@ -10,18 +10,18 @@
|
||||
*/
|
||||
'use strict';
|
||||
|
||||
goog.provide('Blockly.eventHandling');
|
||||
goog.provide('Blockly.browserEvents');
|
||||
|
||||
goog.require('Blockly.Touch');
|
||||
|
||||
|
||||
/**
|
||||
* Blockly opaque event data used to unbind events when using
|
||||
* `Blockly.eventHandling.bindEvent_` and
|
||||
* `Blockly.eventHandling.bindEventWithChecks_`.
|
||||
* `Blockly.browserEvents.bindEvent_` and
|
||||
* `Blockly.browserEvents.bindEventWithChecks_`.
|
||||
* @typedef {!Array.<!Array>}
|
||||
*/
|
||||
Blockly.eventHandling.Data;
|
||||
Blockly.browserEvents.Data;
|
||||
|
||||
/**
|
||||
* Bind an event to a function call. When calling the function, verifies that
|
||||
@@ -38,11 +38,11 @@ Blockly.eventHandling.Data;
|
||||
* should prevent the default handler. False by default. If
|
||||
* opt_noPreventDefault is provided, opt_noCaptureIdentifier must also be
|
||||
* provided.
|
||||
* @return {!Blockly.eventHandling.Data} Opaque data that can be passed to
|
||||
* @return {!Blockly.browserEvents.Data} Opaque data that can be passed to
|
||||
* unbindEvent_.
|
||||
* @public
|
||||
*/
|
||||
Blockly.eventHandling.checkAndBind = function(
|
||||
Blockly.browserEvents.checkAndBind = function(
|
||||
node, name, thisObject, func, opt_noCaptureIdentifier,
|
||||
opt_noPreventDefault) {
|
||||
var handled = false;
|
||||
@@ -106,11 +106,11 @@ Blockly.eventHandling.checkAndBind = function(
|
||||
* @param {string} name Event name to listen to (e.g. 'mousedown').
|
||||
* @param {Object} thisObject The value of 'this' in the function.
|
||||
* @param {!Function} func Function to call when event is triggered.
|
||||
* @return {!Blockly.eventHandling.Data} Opaque data that can be passed to
|
||||
* @return {!Blockly.browserEvents.Data} Opaque data that can be passed to
|
||||
* unbindEvent_.
|
||||
* @public
|
||||
*/
|
||||
Blockly.eventHandling.bind = function(node, name, thisObject, func) {
|
||||
Blockly.browserEvents.bind = function(node, name, thisObject, func) {
|
||||
var wrapFunc = function(e) {
|
||||
if (thisObject) {
|
||||
func.call(thisObject, e);
|
||||
@@ -156,12 +156,12 @@ Blockly.eventHandling.bind = function(node, name, thisObject, func) {
|
||||
|
||||
/**
|
||||
* Unbind one or more events event from a function call.
|
||||
* @param {!Blockly.eventHandling.Data} bindData Opaque data from bindEvent_.
|
||||
* @param {!Blockly.browserEvents.Data} bindData Opaque data from bindEvent_.
|
||||
* This list is emptied during the course of calling this function.
|
||||
* @return {!Function} The function call.
|
||||
* @public
|
||||
*/
|
||||
Blockly.eventHandling.unbind = function(bindData) {
|
||||
Blockly.browserEvents.unbind = function(bindData) {
|
||||
while (bindData.length) {
|
||||
var bindDatum = bindData.pop();
|
||||
var node = bindDatum[0];
|
||||
|
||||
@@ -131,7 +131,7 @@ Blockly.Field = function(value, opt_validator, opt_config) {
|
||||
|
||||
/**
|
||||
* Mouse down event listener data.
|
||||
* @type {?Blockly.EventData}
|
||||
* @type {?Blockly.browserEvents.Data}
|
||||
* @private
|
||||
*/
|
||||
this.mouseDownWrapper_ = null;
|
||||
|
||||
@@ -88,21 +88,21 @@ Blockly.FieldAngle = function(opt_value, opt_validator, opt_config) {
|
||||
|
||||
/**
|
||||
* Wrapper click event data.
|
||||
* @type {?Blockly.EventData}
|
||||
* @type {?Blockly.browserEvents.Data}
|
||||
* @private
|
||||
*/
|
||||
this.clickWrapper_ = null;
|
||||
|
||||
/**
|
||||
* Surface click event data.
|
||||
* @type {?Blockly.EventData}
|
||||
* @type {?Blockly.browserEvents.Data}
|
||||
* @private
|
||||
*/
|
||||
this.clickSurfaceWrapper_ = null;
|
||||
|
||||
/**
|
||||
* Surface mouse move event data.
|
||||
* @type {?Blockly.EventData}
|
||||
* @type {?Blockly.browserEvents.Data}
|
||||
* @private
|
||||
*/
|
||||
this.moveSurfaceWrapper_ = null;
|
||||
|
||||
@@ -61,35 +61,35 @@ Blockly.FieldColour = function(opt_value, opt_validator, opt_config) {
|
||||
|
||||
/**
|
||||
* Mouse click event data.
|
||||
* @type {?Blockly.EventData}
|
||||
* @type {?Blockly.browserEvents.Data}
|
||||
* @private
|
||||
*/
|
||||
this.onClickWrapper_ = null;
|
||||
|
||||
/**
|
||||
* Mouse move event data.
|
||||
* @type {?Blockly.EventData}
|
||||
* @type {?Blockly.browserEvents.Data}
|
||||
* @private
|
||||
*/
|
||||
this.onMouseMoveWrapper_ = null;
|
||||
|
||||
/**
|
||||
* Mouse enter event data.
|
||||
* @type {?Blockly.EventData}
|
||||
* @type {?Blockly.browserEvents.Data}
|
||||
* @private
|
||||
*/
|
||||
this.onMouseEnterWrapper_ = null;
|
||||
|
||||
/**
|
||||
* Mouse leave event data.
|
||||
* @type {?Blockly.EventData}
|
||||
* @type {?Blockly.browserEvents.Data}
|
||||
* @private
|
||||
*/
|
||||
this.onMouseLeaveWrapper_ = null;
|
||||
|
||||
/**
|
||||
* Key down event data.
|
||||
* @type {?Blockly.EventData}
|
||||
* @type {?Blockly.browserEvents.Data}
|
||||
* @private
|
||||
*/
|
||||
this.onKeyDownWrapper_ = null;
|
||||
|
||||
@@ -62,14 +62,14 @@ Blockly.FieldTextInput = function(opt_value, opt_validator, opt_config) {
|
||||
|
||||
/**
|
||||
* Key down event data.
|
||||
* @type {?Blockly.EventData}
|
||||
* @type {?Blockly.browserEvents.Data}
|
||||
* @private
|
||||
*/
|
||||
this.onKeyDownWrapper_ = null;
|
||||
|
||||
/**
|
||||
* Key input event data.
|
||||
* @type {?Blockly.EventData}
|
||||
* @type {?Blockly.browserEvents.Data}
|
||||
* @private
|
||||
*/
|
||||
this.onKeyInputWrapper_ = null;
|
||||
|
||||
@@ -85,7 +85,7 @@ Blockly.FlyoutButton = function(workspace, targetWorkspace, json, isLabel) {
|
||||
|
||||
/**
|
||||
* Mouse up event data.
|
||||
* @type {?Blockly.EventData}
|
||||
* @type {?Blockly.browserEvents.Data}
|
||||
* @private
|
||||
*/
|
||||
this.onMouseUpWrapper_ = null;
|
||||
|
||||
@@ -156,7 +156,7 @@ Blockly.Gesture = function(e, creatorWorkspace) {
|
||||
/**
|
||||
* A handle to use to unbind a mouse move listener at the end of a drag.
|
||||
* Opaque data returned from Blockly.bindEventWithChecks_.
|
||||
* @type {?Blockly.EventData}
|
||||
* @type {?Blockly.browserEvents.Data}
|
||||
* @protected
|
||||
*/
|
||||
this.onMoveWrapper_ = null;
|
||||
@@ -164,7 +164,7 @@ Blockly.Gesture = function(e, creatorWorkspace) {
|
||||
/**
|
||||
* A handle to use to unbind a mouse up listener at the end of a drag.
|
||||
* Opaque data returned from Blockly.bindEventWithChecks_.
|
||||
* @type {?Blockly.EventData}
|
||||
* @type {?Blockly.browserEvents.Data}
|
||||
* @protected
|
||||
*/
|
||||
this.onUpWrapper_ = null;
|
||||
|
||||
10
core/menu.js
10
core/menu.js
@@ -55,35 +55,35 @@ Blockly.Menu = function() {
|
||||
|
||||
/**
|
||||
* Mouse over event data.
|
||||
* @type {?Blockly.EventData}
|
||||
* @type {?Blockly.browserEvents.Data}
|
||||
* @private
|
||||
*/
|
||||
this.mouseOverHandler_ = null;
|
||||
|
||||
/**
|
||||
* Click event data.
|
||||
* @type {?Blockly.EventData}
|
||||
* @type {?Blockly.browserEvents.Data}
|
||||
* @private
|
||||
*/
|
||||
this.clickHandler_ = null;
|
||||
|
||||
/**
|
||||
* Mouse enter event data.
|
||||
* @type {?Blockly.EventData}
|
||||
* @type {?Blockly.browserEvents.Data}
|
||||
* @private
|
||||
*/
|
||||
this.mouseEnterHandler_ = null;
|
||||
|
||||
/**
|
||||
* Mouse leave event data.
|
||||
* @type {?Blockly.EventData}
|
||||
* @type {?Blockly.browserEvents.Data}
|
||||
* @private
|
||||
*/
|
||||
this.mouseLeaveHandler_ = null;
|
||||
|
||||
/**
|
||||
* Key down event data.
|
||||
* @type {?Blockly.EventData}
|
||||
* @type {?Blockly.browserEvents.Data}
|
||||
* @private
|
||||
*/
|
||||
this.onKeyDownHandler_ = null;
|
||||
|
||||
@@ -148,7 +148,7 @@ Blockly.Toolbox = function(workspace) {
|
||||
* Array holding info needed to unbind event handlers.
|
||||
* Used for disposing.
|
||||
* Ex: [[node, name, func], [node, name, func]].
|
||||
* @type {!Array<!Blockly.EventData>}
|
||||
* @type {!Array<!Blockly.browserEvents.Data>}
|
||||
* @protected
|
||||
*/
|
||||
this.boundEvents_ = [];
|
||||
|
||||
@@ -72,7 +72,7 @@ Blockly.TouchGesture = function(e, creatorWorkspace) {
|
||||
* A handle to use to unbind the second touch start or pointer down listener
|
||||
* at the end of a drag.
|
||||
* Opaque data returned from Blockly.bindEventWithChecks_.
|
||||
* @type {?Blockly.EventData}
|
||||
* @type {?Blockly.browserEvents.Data}
|
||||
* @private
|
||||
*/
|
||||
this.onStartWrapper_ = null;
|
||||
|
||||
@@ -48,14 +48,14 @@ Blockly.WorkspaceCommentSvg = function(
|
||||
workspace, content, height, width, opt_id) {
|
||||
/**
|
||||
* Mouse up event data.
|
||||
* @type {?Blockly.EventData}
|
||||
* @type {?Blockly.browserEvents.Data}
|
||||
* @private
|
||||
*/
|
||||
this.onMouseUpWrapper_ = null;
|
||||
|
||||
/**
|
||||
* Mouse move event data.
|
||||
* @type {?Blockly.EventData}
|
||||
* @type {?Blockly.browserEvents.Data}
|
||||
* @private
|
||||
*/
|
||||
this.onMouseMoveWrapper_ = null;
|
||||
|
||||
@@ -17,7 +17,7 @@ goog.require('Blockly.blockRendering');
|
||||
goog.require('Blockly.ConnectionDB');
|
||||
goog.require('Blockly.constants');
|
||||
goog.require('Blockly.ContextMenuRegistry');
|
||||
goog.require('Blockly.eventHandling');
|
||||
goog.require('Blockly.browserEvents');
|
||||
goog.require('Blockly.Events');
|
||||
goog.require('Blockly.Events.BlockCreate');
|
||||
goog.require('Blockly.Events.ThemeChange');
|
||||
@@ -223,7 +223,7 @@ Blockly.utils.object.inherits(Blockly.WorkspaceSvg, Blockly.Workspace);
|
||||
/**
|
||||
* A wrapper function called when a resize event occurs.
|
||||
* You can pass the result to `eventHandling.unbind`.
|
||||
* @type {?Blockly.eventHandling.Data}
|
||||
* @type {?Blockly.browserEvents.Data}
|
||||
* @private
|
||||
*/
|
||||
Blockly.WorkspaceSvg.prototype.resizeHandlerWrapper_ = null;
|
||||
@@ -754,7 +754,7 @@ Blockly.WorkspaceSvg.prototype.getBlockCanvas = function() {
|
||||
|
||||
/**
|
||||
* Save resize handler data so we can delete it later in dispose.
|
||||
* @param {!Blockly.eventHandling.Data} handler Data that can be passed to
|
||||
* @param {!Blockly.browserEvents.Data} handler Data that can be passed to
|
||||
* eventHandling.unbind.
|
||||
*/
|
||||
Blockly.WorkspaceSvg.prototype.setResizeHandlerWrapper = function(handler) {
|
||||
@@ -809,9 +809,9 @@ Blockly.WorkspaceSvg.prototype.createDom = function(opt_backgroundClass) {
|
||||
{'class': 'blocklyBubbleCanvas'}, this.svgGroup_);
|
||||
|
||||
if (!this.isFlyout) {
|
||||
Blockly.eventHandling.checkAndBind(
|
||||
Blockly.browserEvents.checkAndBind(
|
||||
this.svgGroup_, 'mousedown', this, this.onMouseDown_, false, true);
|
||||
Blockly.eventHandling.checkAndBind(
|
||||
Blockly.browserEvents.checkAndBind(
|
||||
this.svgGroup_, 'wheel', this, this.onMouseWheel_);
|
||||
}
|
||||
|
||||
@@ -919,7 +919,7 @@ Blockly.WorkspaceSvg.prototype.dispose = function() {
|
||||
}
|
||||
}
|
||||
if (this.resizeHandlerWrapper_) {
|
||||
Blockly.eventHandling.unbind(this.resizeHandlerWrapper_);
|
||||
Blockly.browserEvents.unbind(this.resizeHandlerWrapper_);
|
||||
this.resizeHandlerWrapper_ = null;
|
||||
}
|
||||
};
|
||||
|
||||
@@ -36,7 +36,7 @@ Blockly.ZoomControls = function(workspace) {
|
||||
/**
|
||||
* A handle to use to unbind the mouse down event handler for zoom reset
|
||||
* button. Opaque data returned from Blockly.bindEventWithChecks_.
|
||||
* @type {?Blockly.EventData}
|
||||
* @type {?Blockly.browserEvents.Data}
|
||||
* @private
|
||||
*/
|
||||
this.onZoomResetWrapper_ = null;
|
||||
@@ -44,7 +44,7 @@ Blockly.ZoomControls = function(workspace) {
|
||||
/**
|
||||
* A handle to use to unbind the mouse down event handler for zoom in button.
|
||||
* Opaque data returned from Blockly.bindEventWithChecks_.
|
||||
* @type {?Blockly.EventData}
|
||||
* @type {?Blockly.browserEvents.Data}
|
||||
* @private
|
||||
*/
|
||||
this.onZoomInWrapper_ = null;
|
||||
@@ -52,7 +52,7 @@ Blockly.ZoomControls = function(workspace) {
|
||||
/**
|
||||
* A handle to use to unbind the mouse down event handler for zoom out button.
|
||||
* Opaque data returned from Blockly.bindEventWithChecks_.
|
||||
* @type {?Blockly.EventData}
|
||||
* @type {?Blockly.browserEvents.Data}
|
||||
* @private
|
||||
*/
|
||||
this.onZoomOutWrapper_ = null;
|
||||
|
||||
@@ -31,14 +31,14 @@ CustomFields.FieldPitch = function(text) {
|
||||
|
||||
/**
|
||||
* Click event data.
|
||||
* @type {?Blockly.EventData}
|
||||
* @type {?Blockly.browserEvents.Data}
|
||||
* @private
|
||||
*/
|
||||
this.clickWrapper_ = null;
|
||||
|
||||
/**
|
||||
* Move event data.
|
||||
* @type {?Blockly.EventData}
|
||||
* @type {?Blockly.browserEvents.Data}
|
||||
* @private
|
||||
*/
|
||||
this.moveWrapper_ = null;
|
||||
|
||||
Reference in New Issue
Block a user