mirror of
https://github.com/google/blockly.git
synced 2026-01-05 08:00:09 +01:00
@@ -138,10 +138,6 @@ Blockly.Cursor.prototype.in = function() {
|
||||
}
|
||||
var newNode = curNode.in();
|
||||
|
||||
if (newNode && newNode.getType() == Blockly.ASTNode.types.OUTPUT) {
|
||||
newNode = newNode.next() || newNode;
|
||||
}
|
||||
|
||||
if (newNode) {
|
||||
this.setCurNode(newNode);
|
||||
}
|
||||
|
||||
@@ -498,11 +498,17 @@ Blockly.navigation.insertBlock = function(block, destConnection) {
|
||||
case Blockly.OUTPUT_VALUE:
|
||||
for (var i = 0; i < block.inputList.length; i++) {
|
||||
var inputConnection = block.inputList[i].connection;
|
||||
if (inputConnection.type === Blockly.INPUT_VALUE &&
|
||||
if (inputConnection && inputConnection.type === Blockly.INPUT_VALUE &&
|
||||
Blockly.navigation.connect_(inputConnection, destConnection)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
// If there are no input values pass the output and destination connections
|
||||
// to connect_ to find a way to connect the two.
|
||||
if (block.outputConnection &&
|
||||
Blockly.navigation.connect_(block.outputConnection, destConnection)) {
|
||||
return true;
|
||||
}
|
||||
break;
|
||||
}
|
||||
Blockly.navigation.warn_('This block can not be inserted at the marked location.');
|
||||
|
||||
@@ -296,7 +296,8 @@ Blockly.Toolbox.prototype.handleAfterTreeSelected_ = function(
|
||||
} else {
|
||||
// Hide the flyout.
|
||||
this.flyout_.hide();
|
||||
if (Blockly.keyboardAccessibilityMode) {
|
||||
if (Blockly.keyboardAccessibilityMode &&
|
||||
!(newNode instanceof Blockly.Toolbox.TreeSeparator)) {
|
||||
Blockly.navigation.setState(Blockly.navigation.STATE_WS);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -52,7 +52,8 @@ Blockly.BasicCursor.prototype.validNode_ = function(node) {
|
||||
type == Blockly.ASTNode.types.INPUT ||
|
||||
type == Blockly.ASTNode.types.FIELD ||
|
||||
type == Blockly.ASTNode.types.NEXT ||
|
||||
type == Blockly.ASTNode.types.PREVIOUS) {
|
||||
type == Blockly.ASTNode.types.PREVIOUS ||
|
||||
type == Blockly.ASTNode.types.WORKSPACE) {
|
||||
isValid = true;
|
||||
}
|
||||
return isValid;
|
||||
@@ -97,8 +98,7 @@ Blockly.BasicCursor.prototype.getNextNode_ = function(node) {
|
||||
var siblingOrParent = this.findSiblingOrParent_(node.out());
|
||||
if (this.validNode_(siblingOrParent)) {
|
||||
return siblingOrParent;
|
||||
} else if (siblingOrParent &&
|
||||
siblingOrParent.getType() !== Blockly.ASTNode.types.WORKSPACE) {
|
||||
} else if (siblingOrParent) {
|
||||
return this.getNextNode_(siblingOrParent);
|
||||
}
|
||||
return null;
|
||||
|
||||
@@ -73,27 +73,28 @@ suite('Cursor', function() {
|
||||
this.workspace.dispose();
|
||||
});
|
||||
|
||||
test('Next - From a block skip over next connection', function() {
|
||||
var blockNode = Blockly.ASTNode.createBlockNode(this.blocks.A);
|
||||
this.cursor.setCurNode(blockNode);
|
||||
test('Next - From a Previous skip over next connection and block', function() {
|
||||
var prevNode = Blockly.ASTNode.createConnectionNode(this.blocks.A.previousConnection);
|
||||
this.cursor.setCurNode(prevNode);
|
||||
this.cursor.next();
|
||||
var curNode = this.cursor.getCurNode();
|
||||
assertEquals(curNode.getLocation(), this.blocks.B.previousConnection);
|
||||
});
|
||||
test('Next - From last block in a stack go to next connection', function() {
|
||||
var blockNode = Blockly.ASTNode.createBlockNode(this.blocks.B);
|
||||
this.cursor.setCurNode(blockNode);
|
||||
var prevNode = Blockly.ASTNode.createConnectionNode(this.blocks.B.previousConnection);
|
||||
this.cursor.setCurNode(prevNode);
|
||||
this.cursor.next();
|
||||
var curNode = this.cursor.getCurNode();
|
||||
assertEquals(curNode.getLocation(), this.blocks.B.nextConnection);
|
||||
});
|
||||
|
||||
test('In - From input skip over output connection', function() {
|
||||
var inputNode = Blockly.ASTNode.createInputNode(this.blocks.A.inputList[0]);
|
||||
this.cursor.setCurNode(inputNode);
|
||||
test('In - From output connection', function() {
|
||||
var fieldBlock = this.blocks.E;
|
||||
var outputNode = Blockly.ASTNode.createConnectionNode(fieldBlock.outputConnection);
|
||||
this.cursor.setCurNode(outputNode);
|
||||
this.cursor.in();
|
||||
var curNode = this.cursor.getCurNode();
|
||||
assertEquals(curNode.getLocation(), this.blocks.E);
|
||||
assertEquals(curNode.getLocation(), fieldBlock.inputList[0].fieldRow[0]);
|
||||
});
|
||||
|
||||
test('Prev - From previous connection skip over next connection', function() {
|
||||
@@ -104,4 +105,13 @@ suite('Cursor', function() {
|
||||
var curNode = this.cursor.getCurNode();
|
||||
assertEquals(curNode.getLocation(), this.blocks.A.previousConnection);
|
||||
});
|
||||
|
||||
test('Out - From field skip over block node', function() {
|
||||
var field = this.blocks.E.inputList[0].fieldRow[0];
|
||||
var fieldNode = Blockly.ASTNode.createFieldNode(field);
|
||||
this.cursor.setCurNode(fieldNode);
|
||||
this.cursor.out();
|
||||
var curNode = this.cursor.getCurNode();
|
||||
assertEquals(curNode.getLocation(), this.blocks.E.outputConnection);
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user