##// END OF EJS Templates
Clear timeout in multi-press keyboard shortcuts.
Brian E. Granger -
Show More
@@ -540,6 +540,7 b' var IPython = (function (IPython) {'
540 540 var ShortcutManager = function (delay) {
541 541 this._shortcuts = {}
542 542 this._counts = {}
543 this._timers = {}
543 544 this.delay = delay || 800; // delay in milliseconds
544 545 }
545 546
@@ -633,17 +634,21 b' var IPython = (function (IPython) {'
633 634 ShortcutManager.prototype.count_handler = function (shortcut, event, data) {
634 635 var that = this;
635 636 var c = this._counts;
637 var t = this._timers;
638 var timer = null;
636 639 if (c[shortcut] === data.count-1) {
637 640 c[shortcut] = 0;
641 var timer = t[shortcut];
642 if (timer) {clearTimeout(timer);}
638 643 return data.handler(event);
639 644 } else {
640 645 c[shortcut] = c[shortcut] + 1;
641 setTimeout(function () {
646 timer = setTimeout(function () {
642 647 c[shortcut] = 0;
643 648 }, that.delay);
649 t[shortcut] = timer;
644 650 }
645 651 return false;
646
647 652 }
648 653
649 654 ShortcutManager.prototype.call_handler = function (event) {
General Comments 0
You need to be logged in to leave comments. Login now