mirror of
https://github.com/google/blockly.git
synced 2026-01-11 10:57:07 +01:00
Make context menus work again; fix dragging from the toolbox with variables.
This commit is contained in:
@@ -133,7 +133,11 @@ Blockly.Tooltip.createDom = function() {
|
||||
Blockly.Tooltip.bindMouseEvents = function(element) {
|
||||
Blockly.bindEvent_(element, 'mouseover', null, Blockly.Tooltip.onMouseOver_);
|
||||
Blockly.bindEvent_(element, 'mouseout', null, Blockly.Tooltip.onMouseOut_);
|
||||
Blockly.bindEvent_(element, 'mousemove', null, Blockly.Tooltip.onMouseMove_);
|
||||
|
||||
// Don't use bindEvent_ for mousemove since that would create a
|
||||
// corresponding touch handler, even though this only makes sense in the
|
||||
// context of a mouseover/mouseout.
|
||||
element.addEventListener('mousemove', Blockly.Tooltip.onMouseMove_, false);
|
||||
};
|
||||
|
||||
/**
|
||||
|
||||
@@ -100,6 +100,7 @@ Blockly.hasClass_ = function(element, className) {
|
||||
*/
|
||||
Blockly.bindEvent_ = function(node, name, thisObject, func,
|
||||
opt_noCaptureIdentifier) {
|
||||
var handled = false;
|
||||
var wrapFunc = function(e) {
|
||||
var captureIdentifier = !opt_noCaptureIdentifier;
|
||||
// Handle each touch point separately. If the event was a mouse event, this
|
||||
@@ -107,7 +108,7 @@ Blockly.bindEvent_ = function(node, name, thisObject, func,
|
||||
var events = Blockly.bindEvent_.splitEventByTouches(e);
|
||||
for (var i = 0, event; event = events[i]; i++) {
|
||||
if (captureIdentifier && !Blockly.shouldHandleEvent(event)) {
|
||||
return;
|
||||
continue;
|
||||
}
|
||||
Blockly.bindEvent_.setClientFromTouch(event);
|
||||
if (thisObject) {
|
||||
@@ -115,6 +116,7 @@ Blockly.bindEvent_ = function(node, name, thisObject, func,
|
||||
} else {
|
||||
func(event);
|
||||
}
|
||||
handled = true;
|
||||
}
|
||||
};
|
||||
|
||||
@@ -126,7 +128,9 @@ Blockly.bindEvent_ = function(node, name, thisObject, func,
|
||||
var touchWrapFunc = function(e) {
|
||||
wrapFunc(e);
|
||||
// Stop the browser from scrolling/zooming the page.
|
||||
e.preventDefault();
|
||||
if (handled) {
|
||||
e.preventDefault();
|
||||
}
|
||||
};
|
||||
for (var i = 0, eventName;
|
||||
eventName = Blockly.bindEvent_.TOUCH_MAP[name][i]; i++) {
|
||||
|
||||
@@ -647,7 +647,8 @@ Blockly.WorkspaceSvg.prototype.paste = function(xmlBlock) {
|
||||
*/
|
||||
Blockly.WorkspaceSvg.prototype.createVariable = function(name) {
|
||||
Blockly.WorkspaceSvg.superClass_.createVariable.call(this, name);
|
||||
if (this.toolbox_ && this.toolbox_.flyout_) {
|
||||
// Don't refresh the toolbox if there's a drag in progress.
|
||||
if (this.toolbox_ && this.toolbox_.flyout_ && !Blockly.Flyout.startFlyout_) {
|
||||
this.toolbox_.refreshSelection();
|
||||
}
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user