From a11ebc8b0a02720f0cd80f72b578c451d1ea3948 Mon Sep 17 00:00:00 2001 From: Takeshi Kanmae Date: Sat, 7 Sep 2013 13:21:27 -0800 Subject: [PATCH 1/3] ESC should be handled by CM if tooltip is not on --- IPython/html/static/notebook/js/codecell.js | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/IPython/html/static/notebook/js/codecell.js b/IPython/html/static/notebook/js/codecell.js index 9c18cafe5..022f821a8 100644 --- a/IPython/html/static/notebook/js/codecell.js +++ b/IPython/html/static/notebook/js/codecell.js @@ -166,7 +166,7 @@ var IPython = (function (IPython) { // triger on keypress (!) otherwise inconsistent event.which depending on plateform // browser and keyboard layout ! // Pressing '(' , request tooltip, don't forget to reappend it - // The second argument says to hide the tooltip if the docstring + // The second argument says to hide the tooltip if the docstring // is actually empty IPython.tooltip.pending(that, true); } else if (event.which === key.UPARROW && event.type === 'keydown') { @@ -179,8 +179,12 @@ var IPython = (function (IPython) { return true; }; } else if (event.which === key.ESC) { - IPython.tooltip.remove_and_cancel_tooltip(true); - return true; + if (!IPython.tooltip._hidden) { + IPython.tooltip.remove_and_cancel_tooltip(true); + return true; + } else { + return false; + } } else if (event.which === key.DOWNARROW && event.type === 'keydown') { // If we are not at the bottom, let CM handle the down arrow and // prevent the global keydown handler from handling it. @@ -272,7 +276,7 @@ var IPython = (function (IPython) { var data = {'cell': this, 'text': text} $([IPython.events]).trigger('set_next_input.Notebook', data); } - + /** * @method _handle_input_request * @private From 9ceedb62d0914c366871933ddad002a5a7af8d88 Mon Sep 17 00:00:00 2001 From: Takeshi Kanmae Date: Sun, 8 Sep 2013 15:54:35 -0800 Subject: [PATCH 2/3] Have remove_and_cancel_tooltip() return a boolean --- IPython/html/static/notebook/js/codecell.js | 7 +------ IPython/html/static/notebook/js/tooltip.js | 19 +++++++++++++------ 2 files changed, 14 insertions(+), 12 deletions(-) diff --git a/IPython/html/static/notebook/js/codecell.js b/IPython/html/static/notebook/js/codecell.js index 022f821a8..492b902f2 100644 --- a/IPython/html/static/notebook/js/codecell.js +++ b/IPython/html/static/notebook/js/codecell.js @@ -179,12 +179,7 @@ var IPython = (function (IPython) { return true; }; } else if (event.which === key.ESC) { - if (!IPython.tooltip._hidden) { - IPython.tooltip.remove_and_cancel_tooltip(true); - return true; - } else { - return false; - } + return IPython.tooltip.remove_and_cancel_tooltip(true); } else if (event.which === key.DOWNARROW && event.type === 'keydown') { // If we are not at the bottom, let CM handle the down arrow and // prevent the global keydown handler from handling it. diff --git a/IPython/html/static/notebook/js/tooltip.js b/IPython/html/static/notebook/js/tooltip.js index 4d324fe86..e1acf48d6 100644 --- a/IPython/html/static/notebook/js/tooltip.js +++ b/IPython/html/static/notebook/js/tooltip.js @@ -161,16 +161,23 @@ var IPython = (function (IPython) { this.code_mirror = null; } + // return true on successfully removing a visible tooltip; otherwise return + // false. Tooltip.prototype.remove_and_cancel_tooltip = function (force) { // note that we don't handle closing directly inside the calltip // as in the completer, because it is not focusable, so won't // get the event. - if (this._sticky == false || force == true) { - this.cancel_stick(); - this._hide(); + if (this._hidden === false) { + if (this._sticky == false || force == true) { + this.cancel_stick(); + this._hide(); + } + this.cancel_pending(); + this.reset_tabs_function(); + return true; + } else { + return false; } - this.cancel_pending(); - this.reset_tabs_function(); } // cancel autocall done after '(' for example. @@ -335,7 +342,7 @@ var IPython = (function (IPython) { if (docstring == null) { docstring = reply.docstring; } - + if (docstring == null) { // For reals this time, no docstring if (this._hide_if_no_docstring) { From 7071ae8d909a61aa5899551dbb8867d144629ebe Mon Sep 17 00:00:00 2001 From: Takeshi Kanmae Date: Sat, 14 Sep 2013 13:41:29 -0600 Subject: [PATCH 3/3] Update boolean tests --- IPython/html/static/notebook/js/tooltip.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/IPython/html/static/notebook/js/tooltip.js b/IPython/html/static/notebook/js/tooltip.js index e1acf48d6..66db57e7c 100644 --- a/IPython/html/static/notebook/js/tooltip.js +++ b/IPython/html/static/notebook/js/tooltip.js @@ -167,8 +167,8 @@ var IPython = (function (IPython) { // note that we don't handle closing directly inside the calltip // as in the completer, because it is not focusable, so won't // get the event. - if (this._hidden === false) { - if (this._sticky == false || force == true) { + if (!this._hidden) { + if (force || !this._sticky) { this.cancel_stick(); this._hide(); }