Merge pull request #5045 from ellisonbg/multipress

Clear timeout in multi-press keyboard shortcuts.
Min RK 12 years ago
commit 8fdee1599c

@ -540,6 +540,7 @@ var IPython = (function (IPython) {
var ShortcutManager = function (delay) {
this._shortcuts = {}
this._counts = {}
this._timers = {}
this.delay = delay || 800; // delay in milliseconds
}
@ -633,17 +634,21 @@ var IPython = (function (IPython) {
ShortcutManager.prototype.count_handler = function (shortcut, event, data) {
var that = this;
var c = this._counts;
var t = this._timers;
var timer = null;
if (c[shortcut] === data.count-1) {
c[shortcut] = 0;
var timer = t[shortcut];
if (timer) {clearTimeout(timer); delete t[shortcut];}
return data.handler(event);
} else {
c[shortcut] = c[shortcut] + 1;
setTimeout(function () {
timer = setTimeout(function () {
c[shortcut] = 0;
}, that.delay);
t[shortcut] = timer;
}
return false;
}
ShortcutManager.prototype.call_handler = function (event) {

Loading…
Cancel
Save