mirror of
https://github.com/scratchfoundation/scratch-blocks.git
synced 2025-08-28 22:10:31 -04:00
Fix longpress in flyout; leave debug messages in
This commit is contained in:
parent
1c025672b3
commit
2774cc1663
5 changed files with 32 additions and 12 deletions
|
@ -531,6 +531,16 @@ Blockly.BlockSvg.prototype.onMouseDown_ = function(e) {
|
|||
return;
|
||||
}
|
||||
if (this.isInFlyout) {
|
||||
// longStart's simulation of right-clicks for longpresses on touch devices
|
||||
// calls the object's onMouseDown, so its code path passes through here only
|
||||
// on touch.
|
||||
// definitely want to show the context menu, clear touch identifier, etc.
|
||||
// what about hideChaff, select, and so on?
|
||||
if (e.type == 'touchstart' && Blockly.isRightButton(e)) {
|
||||
Blockly.Flyout.blockRightClick_(e, this);
|
||||
e.stopPropagation();
|
||||
e.preventDefault();
|
||||
}
|
||||
return;
|
||||
}
|
||||
if (this.isInMutator) {
|
||||
|
|
|
@ -844,6 +844,13 @@ Blockly.Flyout.prototype.addBlockListeners_ = function(root, block, rect) {
|
|||
block.removeSelect));
|
||||
};
|
||||
|
||||
Blockly.Flyout.blockRightClick_ = function(e, block) {
|
||||
Blockly.terminateDrag_();
|
||||
Blockly.hideChaff(true);
|
||||
block.showContextMenu_(e);
|
||||
Blockly.clearTouchIdentifier();
|
||||
};
|
||||
|
||||
/**
|
||||
* Handle a mouse-down on an SVG block in a non-closing flyout.
|
||||
* @param {!Blockly.Block} block The flyout block to copy.
|
||||
|
@ -853,13 +860,11 @@ Blockly.Flyout.prototype.addBlockListeners_ = function(root, block, rect) {
|
|||
Blockly.Flyout.prototype.blockMouseDown_ = function(block) {
|
||||
var flyout = this;
|
||||
return function(e) {
|
||||
Blockly.terminateDrag_();
|
||||
Blockly.hideChaff(true);
|
||||
if (Blockly.isRightButton(e)) {
|
||||
// Right-click.
|
||||
block.showContextMenu_(e);
|
||||
Blockly.clearTouchIdentifier();
|
||||
Blockly.Flyout.blockRightClick_(e, block);
|
||||
} else {
|
||||
Blockly.terminateDrag_();
|
||||
Blockly.hideChaff(true);
|
||||
// Left-click (or middle click)
|
||||
Blockly.Css.setCursor(Blockly.Css.Cursor.CLOSED);
|
||||
// Record the current mouse position.
|
||||
|
@ -911,8 +916,8 @@ Blockly.Flyout.prototype.onMouseDown_ = function(e) {
|
|||
* @private
|
||||
*/
|
||||
Blockly.Flyout.prototype.onMouseUp_ = function(e) {
|
||||
Blockly.clearTouchIdentifier();
|
||||
if (!this.workspace_.isDragging()) {
|
||||
Blockly.clearTouchIdentifier();
|
||||
if (this.autoClose) {
|
||||
this.createBlockFunc_(Blockly.Flyout.startBlock_)(
|
||||
Blockly.Flyout.startDownEvent_);
|
||||
|
@ -976,9 +981,11 @@ Blockly.Flyout.prototype.onMouseMoveBlock_ = function(e) {
|
|||
|
||||
var createBlock = this.determineDragIntention_(dx, dy);
|
||||
if (createBlock) {
|
||||
Blockly.longStop_();
|
||||
this.createBlockFunc_(Blockly.Flyout.startBlock_)(
|
||||
Blockly.Flyout.startDownEvent_);
|
||||
} else if (this.dragMode_ == Blockly.DRAG_FREE) {
|
||||
Blockly.longStop_();
|
||||
// Do a scroll.
|
||||
this.onMouseMove_(e);
|
||||
}
|
||||
|
|
|
@ -359,13 +359,14 @@ Blockly.inject.loadSounds_ = function(pathToMedia, workspace) {
|
|||
while (soundBinds.length) {
|
||||
Blockly.unbindEvent_(soundBinds.pop());
|
||||
}
|
||||
// These are bound on mouse/touch events with Blockly.bindEvent_, so they
|
||||
// restrict the touch identifier that will be recognized. But this is
|
||||
// really something that happens on a click, not a drag, so that's not
|
||||
// necessary.
|
||||
//Blockly.clearTouchIdentifier();
|
||||
workspace.preloadAudio_();
|
||||
};
|
||||
|
||||
// These are bound on mouse/touch events with Blockly.bindEvent_, so they
|
||||
// restrict the touch identifier that will be recognized. But this is
|
||||
// really something that happens on a click, not a drag, so that's not
|
||||
// necessary.
|
||||
|
||||
// Android ignores any sound not loaded as a result of a user action.
|
||||
soundBinds.push(
|
||||
Blockly.bindEvent_(document, 'mousemove', null, unbindSounds, true));
|
||||
|
|
|
@ -599,6 +599,7 @@ Blockly.Scrollbar.prototype.setVisible = function(visible) {
|
|||
* @private
|
||||
*/
|
||||
Blockly.Scrollbar.prototype.onMouseDownBar_ = function(e) {
|
||||
Blockly.clearTouchIdentifier(); // This is really a click.
|
||||
this.cleanUp_();
|
||||
if (Blockly.isRightButton(e)) {
|
||||
// Right-click.
|
||||
|
|
|
@ -101,7 +101,7 @@ Blockly.hasClass_ = function(element, className) {
|
|||
Blockly.bindEvent_ = function(node, name, thisObject, func,
|
||||
opt_noCaptureIdentifier) {
|
||||
var wrapFunc = function(e) {
|
||||
var captureIdentifier = opt_noCaptureIdentifier || true;
|
||||
var captureIdentifier = !opt_noCaptureIdentifier;
|
||||
// Handle each touch point separately. If the event was a mouse event, this
|
||||
// will hand back an array with one element, which we're fine handling.
|
||||
var events = Blockly.bindEvent_.splitEventByTouches(e);
|
||||
|
@ -175,6 +175,7 @@ Blockly.isMouseOrTouchEvent = function(e) {
|
|||
};
|
||||
|
||||
/**
|
||||
* TODO (rachel-fenichel): consider moving all of this to touch.js
|
||||
* Split an event into an array of events, one per changed touch or mouse
|
||||
* point.
|
||||
* @param {!Event} e A mouse event or a touch event with one or more changed
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue