Skip to content
Permalink
Browse files

Make blocks collapse/expand on double click (#1809)

Change-Id: Ia4964537d457316824325bdf351a26820a51144a
  • Loading branch information
ewpatton authored and SusanRatiLane committed Sep 6, 2019
1 parent 1f5abd5 commit ad97f10985164c1ded8bfa75a9992ee0928aedca
Showing with 20 additions and 0 deletions.
  1. +20 −0 appinventor/blocklyeditor/src/workspace_svg.js
@@ -1064,6 +1064,26 @@ Blockly.WorkspaceSvg.prototype.fireChangeListener = function(event) {
oldParent && this.requestErrorChecking(oldParent);
block && this.requestErrorChecking(block);
}

// Double-click to collapse/expand blocks
if (event instanceof Blockly.Events.Ui && event.element === 'click') {
if (this.doubleClickPid_) {
clearTimeout(this.doubleClickPid_);
this.doubleClickPid_ = undefined;
if (event.blockId === this.doubleClickBlock_) {
// double click
var block = this.getBlockById(this.doubleClickBlock_);
block.setCollapsed(!block.isCollapsed());
return;
}
}
if (!this.doubleClickPid_) {
this.doubleClickBlock_ = event.blockId;
this.doubleClickPid_ = setTimeout(function() {
this.doubleClickPid_ = undefined;
}.bind(this), 500); // windows uses 500ms as the default speed; seems reasonable enough
}
}
};

/**

0 comments on commit ad97f10

Please sign in to comment.
You can’t perform that action at this time.