##// END OF EJS Templates
DRY: factor out common handle_keyevent method...
Paul Ivanov -
Show More
@@ -230,6 +230,26 b' var IPython = (function (IPython) {'
230 230 };
231 231
232 232 /**
233 * Either delegates keyboard shortcut handling to either IPython keyboard
234 * manager when in command mode, or CodeMirror when in edit mode
235 *
236 * @method handle_keyevent
237 * @param {CodeMirror} editor - The codemirror instance bound to the cell
238 * @param {event} event -
239 * @return {Boolean} `true` if CodeMirror should ignore the event, `false` Otherwise
240 */
241 CodeCell.prototype.handle_keyevent = function (editor, event) {
242
243 // console.log('CM', this.mode, event.which, event.type)
244
245 if (this.mode === 'command') {
246 return true;
247 } else if (this.mode === 'edit') {
248 return this.handle_codemirror_keyevent(editor, event);
249 }
250 };
251
252 /**
233 253 * @method at_top
234 254 * @return {Boolean}
235 255 */
@@ -171,16 +171,6 b' var IPython = (function (IPython) {'
171 171 );
172 172 };
173 173
174 CodeCell.prototype.handle_keyevent = function (editor, event) {
175
176 // console.log('CM', this.mode, event.which, event.type)
177
178 if (this.mode === 'command') {
179 return true;
180 } else if (this.mode === 'edit') {
181 return this.handle_codemirror_keyevent(editor, event);
182 }
183 };
184 174
185 175 /**
186 176 * This method gets called in CodeMirror's onKeyDown/onKeyPress
@@ -113,22 +113,11 b' var IPython = (function (IPython) {'
113 113 });
114 114 };
115 115
116 TextCell.prototype.handle_keyevent = function (editor, event) {
117
118 // console.log('CM', this.mode, event.which, event.type)
119
120 if (this.mode === 'command') {
121 return true;
122 } else if (this.mode === 'edit') {
123 return this.handle_codemirror_keyevent(editor, event);
124 }
125 };
126
127 116 /**
128 117 * This method gets called in CodeMirror's onKeyDown/onKeyPress
129 118 * handlers and is used to provide custom key handling.
130 119 *
131 * Subclass should override this method to have custom handeling
120 * Subclass should override this method to have custom handling
132 121 *
133 122 * @method handle_codemirror_keyevent
134 123 * @param {CodeMirror} editor - The codemirror instance bound to the cell
General Comments 0
You need to be logged in to leave comments. Login now