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