Commit ad97f109 authored by Evan W. Patton's avatar Evan W. Patton Committed by Susan Rati Lane

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

Change-Id: Ia4964537d457316824325bdf351a26820a51144a
parent 1f5abd5f
...@@ -1064,6 +1064,26 @@ Blockly.WorkspaceSvg.prototype.fireChangeListener = function(event) { ...@@ -1064,6 +1064,26 @@ Blockly.WorkspaceSvg.prototype.fireChangeListener = function(event) {
oldParent && this.requestErrorChecking(oldParent); oldParent && this.requestErrorChecking(oldParent);
block && this.requestErrorChecking(block); 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
}
}
}; };
/** /**
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment