After marking a spot or copying a block in the workspace, move the active desc to the parent.

This commit is contained in:
Sean Lip
2016-08-05 17:20:41 -07:00
parent f7b0c1b5e6
commit 78ae42b267

View File

@@ -266,6 +266,7 @@ blocklyApp.TreeService = ng.core
while (dfsStack.length) {
var currentNode = dfsStack.shift();
if (currentNode.tagName == 'BUTTON') {
this.moveActiveDescToParent(treeId);
currentNode.click();
break;
} else if (currentNode.tagName == 'INPUT') {
@@ -307,16 +308,7 @@ blocklyApp.TreeService = ng.core
}
} else if (e.keyCode == 37) {
// Left arrow key. Go up a level, if possible.
var nextNode = activeDesc.parentNode;
if (this.isButtonOrFieldNode_(activeDesc)) {
nextNode = nextNode.parentNode;
}
while (nextNode && nextNode.tagName != 'LI') {
nextNode = nextNode.parentNode;
}
if (nextNode) {
this.setActiveDesc(nextNode.id, treeId);
}
this.moveActiveDescToParent(treeId);
} else if (e.keyCode == 38) {
// Up arrow key. Go to the previous sibling, if possible.
var prevSibling = this.getPreviousSibling(activeDesc);
@@ -342,6 +334,19 @@ blocklyApp.TreeService = ng.core
}
}
},
moveActiveDescToParent: function(treeId) {
var activeDesc = document.getElementById(this.getActiveDescId(treeId));
var nextNode = activeDesc.parentNode;
if (this.isButtonOrFieldNode_(activeDesc)) {
nextNode = nextNode.parentNode;
}
while (nextNode && nextNode.tagName != 'LI') {
nextNode = nextNode.parentNode;
}
if (nextNode) {
this.setActiveDesc(nextNode.id, treeId);
}
},
getFirstChild: function(element) {
if (!element) {
return element;