added new use_shortcut method to shortcuts

this way, you can ask if a particular event will be handled by the
shortcuts system. This takes away the need to special-case many
different possible keys which should be ignored by codemirror by
ignoring them en masse.
Paul Ivanov 12 years ago
parent b9e448b160
commit 2c9ff376a2

@ -237,6 +237,12 @@ IPython.keyboard = (function (IPython) {
return true;
}
ShortcutManager.prototype.use_shortcut = function (event) {
var shortcut = event_to_shortcut(event);
var data = this._shortcuts[shortcut];
return !( data === undefined )
}
return {
keycodes : keycodes,
inv_keycodes : inv_keycodes,

@ -169,7 +169,11 @@ var IPython = (function (IPython) {
*/
Cell.prototype.handle_codemirror_keyevent = function (editor, event) {
var that = this;
var shortcuts = IPython.keyboard_manager.edit_shortcuts;
// if this is an edit_shortcuts shortcut, we've already handled it.
if (shortcuts.use_shortcut(event)) { return true; }
if (event.keyCode === keycodes.enter && (event.shiftKey || event.ctrlKey || event.altKey)) {
// Always ignore shift-enter in CodeMirror as we handle it.
return true;

Loading…
Cancel
Save