Skip to content

Commit 43c13e5

Browse files
author
dean.wyatte
committed
pass even through to notebook when scratchpad isn't focuesd
1 parent de75a09 commit 43c13e5

File tree

1 file changed

+14
-3
lines changed

1 file changed

+14
-3
lines changed

main.js

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,10 @@ define(function (require, exports, module) {
4141
cell.refresh();
4242
this.collapse();
4343

44-
// override shift-enter to execute me if I'm focused instead of the notebook's cell
44+
// override ctrl/shift-enter to execute me if I'm focused instead of the notebook's cell
45+
var execute_and_select_action = this.km.actions.register({
46+
handler: $.proxy(this.execute_and_select_event, this),
47+
}, 'scratchpad-execute-and-select');
4548
var execute_action = this.km.actions.register({
4649
handler: $.proxy(this.execute_event, this),
4750
}, 'scratchpad-execute');
@@ -50,7 +53,7 @@ define(function (require, exports, module) {
5053
}, 'scratchpad-toggle');
5154

5255
var shortcuts = {
53-
'shift-enter': execute_action,
56+
'shift-enter': execute_and_select_action,
5457
'ctrl-enter': execute_action,
5558
'ctrl-b': toggle_action,
5659
}
@@ -94,14 +97,22 @@ define(function (require, exports, module) {
9497
this.cell.element.hide();
9598
};
9699

97-
Scratchpad.prototype.execute_event = function (evt) {
100+
Scratchpad.prototype.execute_and_select_event = function (evt) {
98101
if (utils.is_focused(this.element)) {
99102
this.cell.execute();
100103
} else {
101104
this.notebook.execute_cell_and_select_below();
102105
}
103106
};
104107

108+
Scratchpad.prototype.execute_event = function (evt) {
109+
if (utils.is_focused(this.element)) {
110+
this.cell.execute();
111+
} else {
112+
this.notebook.execute_cell();
113+
}
114+
};
115+
105116
function setup_scratchpad () {
106117
// lazy, hook it up to Jupyter.notebook as the handle on all the singletons
107118
console.log("Setting up scratchpad");

0 commit comments

Comments
 (0)