mirror of
https://github.com/google/blockly.git
synced 2026-01-07 17:10:11 +01:00
Remove selection in Block Factory when switching modes.
This commit is contained in:
@@ -325,6 +325,26 @@ Blockly.createSvgElement = function(name, attrs, opt_parent) {
|
||||
return e;
|
||||
};
|
||||
|
||||
/**
|
||||
* Deselect any selections on the webpage.
|
||||
* Chrome will select text outside the SVG when double-clicking.
|
||||
* Deselect this text, so that it doesn't mess up any subsequent drag.
|
||||
*/
|
||||
Blockly.removeAllRanges = function() {
|
||||
if (getSelection()) {
|
||||
setTimeout(function() {
|
||||
try {
|
||||
var selection = getSelection();
|
||||
if (!selection.isCollapsed) {
|
||||
selection.removeAllRanges();
|
||||
}
|
||||
} catch (e) {
|
||||
// MSIE throws 'error 800a025e' here.
|
||||
}
|
||||
}, 0);
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Is this event a right-click?
|
||||
* @param {!Event} e Mouse event.
|
||||
|
||||
Reference in New Issue
Block a user