From: Jörn Zaefferer Date: Wed, 13 Jul 2011 22:06:16 +0000 (-0400) Subject: Tooltip: Handle ESCAPE key event to close tooltip when target has focus. X-Git-Tag: 1.9m6~98^2~5 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=2803417dc44c6147cee14f46ba0ccfa29218a257;p=jquery-ui.git Tooltip: Handle ESCAPE key event to close tooltip when target has focus. --- diff --git a/ui/jquery.ui.tooltip.js b/ui/jquery.ui.tooltip.js index f19061bc3..5e32459fc 100644 --- a/ui/jquery.ui.tooltip.js +++ b/ui/jquery.ui.tooltip.js @@ -148,7 +148,14 @@ $.widget( "ui.tooltip", { this._bind( target, { mouseleave: "close", - blur: "close" + blur: "close", + keyup: function( event ) { + if ( event.keyCode == $.ui.keyCode.ESCAPE ) { + var fakeEvent = $.Event(event); + fakeEvent.currentTarget = target[0]; + this.close( fakeEvent, true ); + } + } }); }, @@ -176,7 +183,7 @@ $.widget( "ui.tooltip", { delete that.tooltips[ this.id ]; }); - target.unbind( "mouseleave.tooltip blur.tooltip" ); + target.unbind( "mouseleave.tooltip blur.tooltip keyup.tooltip" ); this._trigger( "close", event, { tooltip: tooltip } ); },