Skip to content

Commit 3af8c24

Browse files
committed
LEFT and RIGHT key arrow shortcuts
1 parent e1108ec commit 3af8c24

2 files changed

Lines changed: 18 additions & 0 deletions

File tree

‎v3/js/opt-frontend-common.js‎

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1483,6 +1483,22 @@ function executeCodeAndCreateViz(codeToExec,
14831483
}
14841484
return [false]; // pass through to let other hooks keep handling
14851485
});
1486+
1487+
1488+
// bind keyboard shortcuts if we're not in embedded mode
1489+
// (i.e., in an iframe)
1490+
if (!myVisualizer.embeddedMode) {
1491+
$(document).off('keydown'); // clear first before rebinding, just to be paranoid
1492+
$(document).keydown(function(e) {
1493+
if (myVisualizer) {
1494+
if (e.keyCode === 37) { // left
1495+
myVisualizer.stepBack();
1496+
} else if (e.keyCode === 39) { // right
1497+
myVisualizer.stepForward();
1498+
}
1499+
}
1500+
});
1501+
}
14861502
}
14871503
// SUPER HACK -- slip in backendOptionsObj as an extra field
14881504
if (myVisualizer) {

‎v3/js/pytutor.js‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,7 @@ var curVisualizerID = 1; // global to uniquely identify each ExecutionVisualizer
8484
// embeddedMode - shortcut for hideOutput=true, allowEditAnnotations=false,
8585
// codeDivWidth=this.DEFAULT_EMBEDDED_CODE_DIV_WIDTH,
8686
// codeDivHeight=this.DEFAULT_EMBEDDED_CODE_DIV_HEIGHT
87+
// (and don't activate keyboard shortcuts!)
8788
// disableHeapNesting - if true, then render all heap objects at the top level (i.e., no nested objects)
8889
// drawParentPointers - if true, then draw environment diagram parent pointers for all frames
8990
// WARNING: there are hard-to-debug MEMORY LEAKS associated with activating this option
@@ -570,6 +571,7 @@ ExecutionVisualizer.prototype.render = function() {
570571
this.domRoot.find('#stepAnnotationEditor').hide();
571572

572573
if (this.params.embeddedMode) {
574+
this.embeddedMode = true;
573575
this.params.hideOutput = true; // put this before hideOutput handler
574576

575577
// don't override if they've already been set!

0 commit comments

Comments
 (0)