Fix interaction between mouse and keyboard (#3070)

This commit is contained in:
alschmiedt
2019-09-23 11:07:59 -07:00
committed by GitHub
parent c16ea62b58
commit f3b4fc0732
3 changed files with 27 additions and 6 deletions

View File

@@ -663,6 +663,9 @@ Blockly.Gesture.prototype.handleWsStart = function(e, ws) {
this.setStartWorkspace_(ws);
this.mostRecentEvent_ = e;
this.doStart(e);
if (Blockly.keyboardAccessibilityMode) {
Blockly.navigation.setState(Blockly.navigation.STATE_WS);
}
};
/**

View File

@@ -107,6 +107,15 @@ Blockly.navigation.removeMark_ = function() {
Blockly.getMainWorkspace().getMarker().hide();
};
/**
* Set the current navigation state.
* @param {number} newState The new navigation state.
* @package
*/
Blockly.navigation.setState = function(newState) {
Blockly.navigation.currentState_ = newState;
};
/**
* Gets the top node on a block.
* This is either the previous connection, output connection or the block.
@@ -133,20 +142,23 @@ Blockly.navigation.getTopNode = function(block) {
/************************/
/**
* Set the state to the toolbox state and the current category as the first
* If a toolbox exists, set the navigation state to toolbox and select the first
* category in the toolbox.
* category.
* @private
*/
Blockly.navigation.focusToolbox_ = function() {
Blockly.navigation.resetFlyout_(false /* shouldHide */);
Blockly.navigation.currentState_ = Blockly.navigation.STATE_TOOLBOX;
var workspace = Blockly.getMainWorkspace();
var toolbox = workspace.getToolbox();
if (toolbox) {
Blockly.navigation.currentState_ = Blockly.navigation.STATE_TOOLBOX;
Blockly.navigation.resetFlyout_(false /* shouldHide */);
if (!Blockly.getMainWorkspace().getMarker().getCurNode()) {
Blockly.navigation.markAtCursor_();
if (!Blockly.getMainWorkspace().getMarker().getCurNode()) {
Blockly.navigation.markAtCursor_();
}
toolbox.selectFirstCategory();
}
toolbox.selectFirstCategory();
};
/***********************/

View File

@@ -260,9 +260,15 @@ Blockly.Toolbox.prototype.handleAfterTreeSelected_ = function(
if (this.lastCategory_ != newNode) {
this.flyout_.scrollToStart();
}
if (Blockly.keyboardAccessibilityMode) {
Blockly.navigation.setState(Blockly.navigation.STATE_TOOLBOX);
}
} else {
// Hide the flyout.
this.flyout_.hide();
if (Blockly.keyboardAccessibilityMode) {
Blockly.navigation.setState(Blockly.navigation.STATE_WS);
}
}
if (oldNode != newNode && oldNode != this) {
var event = new Blockly.Events.Ui(null, 'category',