mirror of
https://github.com/google/blockly.git
synced 2026-03-10 07:10:11 +01:00
More comprehensive approach to gesture detection.
Search all workspaces. The flaw with looking at the workspace of the selected block is that dragging a workspace is a gesture but has no selected block.
This commit is contained in:
@@ -960,10 +960,9 @@ Blockly.Gesture.prototype.getInsertionMarkers = function() {
|
||||
* @return {boolean} True if gesture is occurring.
|
||||
*/
|
||||
Blockly.Gesture.inProgress = function() {
|
||||
// If a drag is occurring, then it involves a selected block on a workspace.
|
||||
if (Blockly.selected) {
|
||||
var currentWorkspace = Blockly.selected.workspace;
|
||||
if (currentWorkspace && currentWorkspace.currentGesture_) {
|
||||
var workspaces = Blockly.Workspace.getAll();
|
||||
for (var i = 0, workspace; workspace = workspaces[i]; i++) {
|
||||
if (workspace.currentGesture_) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -421,8 +421,8 @@ Blockly.init_ = function(mainWorkspace) {
|
||||
Blockly.inject.bindDocumentEvents_ = function() {
|
||||
if (!Blockly.documentEventsBound_) {
|
||||
Blockly.bindEventWithChecks_(document, 'scroll', null, function() {
|
||||
for (var workspaceId in Blockly.Workspace.WorkspaceDB_) {
|
||||
var workspace = Blockly.Workspace.WorkspaceDB_[workspaceId];
|
||||
var workspaces = Blockly.Workspace.getAll();
|
||||
for (var i = 0, workspace; workspace = workspaces[i]; i++) {
|
||||
if (workspace.updateInverseScreenCTM) {
|
||||
workspace.updateInverseScreenCTM();
|
||||
}
|
||||
|
||||
@@ -734,6 +734,18 @@ Blockly.Workspace.getById = function(id) {
|
||||
return Blockly.Workspace.WorkspaceDB_[id] || null;
|
||||
};
|
||||
|
||||
/**
|
||||
* Find all workspaces.
|
||||
* @return {!Array.<!Blockly.Workspace>} Array of workspaces.
|
||||
*/
|
||||
Blockly.Workspace.getAll = function() {
|
||||
var workspaces = [];
|
||||
for (var workspaceId in Blockly.Workspace.WorkspaceDB_) {
|
||||
workspaces.push(Blockly.Workspace.WorkspaceDB_[workspaceId]);
|
||||
}
|
||||
return workspaces;
|
||||
};
|
||||
|
||||
// Export symbols that would otherwise be renamed by Closure compiler.
|
||||
Blockly.Workspace.prototype['clear'] = Blockly.Workspace.prototype.clear;
|
||||
Blockly.Workspace.prototype['clearUndo'] =
|
||||
|
||||
Reference in New Issue
Block a user