From 764452eb1043a0b53639b50cf576b7255502b215 Mon Sep 17 00:00:00 2001 From: Neil Fraser Date: Tue, 17 Mar 2015 12:20:56 -0700 Subject: [PATCH] Squeltch double-click highlighting on workspace and toolbox. --- core/blockly.js | 20 +++++++++----------- core/toolbox.js | 1 + 2 files changed, 10 insertions(+), 11 deletions(-) diff --git a/core/blockly.js b/core/blockly.js index 9b7c9cf68..ee2a231f4 100644 --- a/core/blockly.js +++ b/core/blockly.js @@ -291,6 +291,7 @@ Blockly.onMouseDown_ = function(e) { Blockly.showContextMenu_(e); } else if ((Blockly.readOnly || isTargetSvg) && Blockly.mainWorkspace.scrollbar) { + Blockly.removeAllRanges(); // If the workspace is editable, only allow dragging when gripping empty // space. Otherwise, allow dragging when gripping anywhere. Blockly.mainWorkspace.dragMode = true; @@ -534,17 +535,14 @@ Blockly.hideChaff = function(opt_allowToolbox) { * Deselect this text, so that it doesn't mess up any subsequent drag. */ Blockly.removeAllRanges = function() { - if (window.getSelection) { // W3 - var sel = window.getSelection(); - if (sel && sel.removeAllRanges) { - setTimeout(function() { - try { - window.getSelection().removeAllRanges(); - } catch (e) { - // MSIE throws 'error 800a025e' here. - } - }, 0); - } + if (getSelection()) { + setTimeout(function() { + try { + getSelection().removeAllRanges(); + } catch (e) { + // MSIE throws 'error 800a025e' here. + } + }, 0); } }; diff --git a/core/toolbox.js b/core/toolbox.js index 794ccdde1..fe3cdd0cc 100644 --- a/core/toolbox.js +++ b/core/toolbox.js @@ -299,6 +299,7 @@ Blockly.Toolbox.TreeControl.prototype.createNode = function(opt_html) { * @override */ Blockly.Toolbox.TreeControl.prototype.setSelectedItem = function(node) { + Blockly.removeAllRanges(); if (this.selectedItem_ == node) { return; }