[gnome-shell] [lg] Close inspector on Esc



commit 083b1c9d8b5007a7e4d47a915478eae367bfea9c
Author: Dan Winship <danw gnome org>
Date:   Wed Jul 21 11:37:08 2010 -0400

    [lg] Close inspector on Esc
    
    https://bugzilla.gnome.org/show_bug.cgi?id=624940

 js/ui/lookingGlass.js |    9 +++++++++
 1 files changed, 9 insertions(+), 0 deletions(-)
---
diff --git a/js/ui/lookingGlass.js b/js/ui/lookingGlass.js
index 7f6f4c1..5c350d1 100644
--- a/js/ui/lookingGlass.js
+++ b/js/ui/lookingGlass.js
@@ -382,10 +382,12 @@ Inspector.prototype = {
         this._borderPaintTarget = null;
         this._borderPaintId = null;
         eventHandler.connect('destroy', Lang.bind(this, this._onDestroy));
+        eventHandler.connect('key-press-event', Lang.bind(this, this._onKeyPressEvent));
         eventHandler.connect('button-press-event', Lang.bind(this, this._onButtonPressEvent));
         eventHandler.connect('scroll-event', Lang.bind(this, this._onScrollEvent));
         eventHandler.connect('motion-event', Lang.bind(this, this._onMotionEvent));
         Clutter.grab_pointer(eventHandler);
+        Clutter.grab_keyboard(eventHandler);
 
         // this._target is the actor currently shown by the inspector.
         // this._pointerTarget is the actor directly under the pointer.
@@ -398,6 +400,7 @@ Inspector.prototype = {
 
     _close: function() {
         Clutter.ungrab_pointer(this._eventHandler);
+        Clutter.ungrab_keyboard(this._eventHandler);
         this._eventHandler.destroy();
         this.emit('closed');
     },
@@ -407,6 +410,12 @@ Inspector.prototype = {
             this._borderPaintTarget.disconnect(this._borderPaintId);
     },
 
+    _onKeyPressEvent: function (actor, event) {
+        if (event.get_key_symbol() == Clutter.Escape)
+            this._close();
+        return true;
+    },
+
     _onButtonPressEvent: function (actor, event) {
         if (this._target) {
             let [stageX, stageY] = event.get_coords();



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]