Don't fire click when editing a field. Issue #336 part 1.

This commit is contained in:
Neil Fraser
2016-04-19 20:50:26 -07:00
parent d6f7eb3a3c
commit 6d58f7959f
2 changed files with 13 additions and 10 deletions

View File

@@ -127,6 +127,11 @@ Blockly.BlockSvg.prototype.initSvg = function() {
* Select this block. Highlight it visually.
*/
Blockly.BlockSvg.prototype.select = function() {
if (this.isShadow() && this.getParent()) {
// Shadow blocks should not be selected.
this.getParent().select();
return;
}
if (Blockly.selected == this) {
return;
}
@@ -563,7 +568,8 @@ Blockly.BlockSvg.prototype.onMouseDown_ = function(e) {
* @private
*/
Blockly.BlockSvg.prototype.onMouseUp_ = function(e) {
if (Blockly.dragMode_ != Blockly.DRAG_FREE) {
if (Blockly.dragMode_ != Blockly.DRAG_FREE &&
!Blockly.WidgetDiv.isVisible()) {
Blockly.Events.fire(
new Blockly.Events.Ui(this, 'click', undefined, undefined));
}

View File

@@ -233,15 +233,12 @@ Blockly.onKeyDown_ = function(e) {
Blockly.hideChaff();
} else if (e.keyCode == 8 || e.keyCode == 46) {
// Delete or backspace.
try {
if (Blockly.selected && Blockly.selected.isDeletable()) {
deleteBlock = true;
}
} finally {
// Stop the browser from going back to the previous page.
// Use a finally so that any error in delete code above doesn't disappear
// from the console when the page rolls back.
e.preventDefault();
// Stop the browser from going back to the previous page.
// Do this first to prevent an error in the delete code from resulting in
// data loss.
e.preventDefault();
if (Blockly.selected && Blockly.selected.isDeletable()) {
deleteBlock = true;
}
} else if (e.altKey || e.ctrlKey || e.metaKey) {
if (Blockly.selected &&