Add listener for flyout events to playground. (#4035)

* Update workspace click and add listener for flyout events to playground.

* Fix test.

* Fix typing error

* change variable

* Update variable.
This commit is contained in:
Monica Kozbial
2020-07-20 14:00:03 -07:00
committed by GitHub
parent 3e2f66c506
commit 64488c1402
3 changed files with 25 additions and 5 deletions

View File

@@ -774,7 +774,7 @@ Blockly.Gesture.prototype.doWorkspaceClick_ = function(e) {
} else if (Blockly.selected) {
Blockly.selected.unselect();
}
this.fireWorkspaceClick_(ws);
this.fireWorkspaceClick_(this.startWorkspace_ || ws);
};
/* End functions defining what actions to take to execute clicks on each type

View File

@@ -70,7 +70,7 @@ suite('Gesture', function() {
gestureIsFieldClick_InFlyoutHelper.call(this, flyout, true);
});
test('Workspace click - Shift click enters accessibility mode', function() {
test('Workspace click in accessibility mode - moves the cursor', function() {
var event = {
shiftKey : true,
clientX : 10,

View File

@@ -147,8 +147,10 @@ function start() {
document.getElementById('importExport').value = text;
}
// Restore event logging state.
var state = sessionStorage.getItem('logEvents');
logEvents(Boolean(Number(state)));
var logMainEventsState = sessionStorage.getItem('logEvents');
logEvents(Boolean(Number(logMainEventsState)));
var logToolboxFlyoutEventsState = sessionStorage.getItem('logFlyoutEvents');
logFlyoutEvents(Boolean(Number(logToolboxFlyoutEventsState)));
} else {
// MSIE 11 does not support sessionStorage on file:// URLs.
logEvents(false);
@@ -361,6 +363,20 @@ function logEvents(state) {
}
}
function logFlyoutEvents(state) {
var checkbox = document.getElementById('logFlyoutCheck');
checkbox.checked = state;
if (sessionStorage) {
sessionStorage.setItem('logFlyoutEvents', Number(state));
}
var flyoutWorkspace = workspace.getFlyout().getWorkspace();
if (state) {
flyoutWorkspace.addChangeListener(logger);
} else {
flyoutWorkspace.removeChangeListener(logger);
}
}
function configureContextMenu(menuOptions, e) {
var screenshotOption = {
text: 'Download Screenshot',
@@ -537,9 +553,13 @@ var spaghettiXml = [
</p>
<ul class="playgroundToggleOptions">
<li>
<label for="logCheck">Log events:</label>
<label for="logCheck">Log main workspace events:</label>
<input type="checkbox" onclick="logEvents(this.checked)" id="logCheck">
</li>
<li>
<label for="logFlyoutCheck">Log flyout events:</label>
<input type="checkbox" onclick="logFlyoutEvents(this.checked)" id="logFlyoutCheck">
</li>
</ul>