Change event handling so Escape always works

Until now LookingGlass could only be closed using the Escape
key when the Evaluator class was active, as the relevant code
was associated to the text input field; this moves it into a
global event handler instead which works everywhere in LG.
This commit is contained in:
Siegfried-Angel Gevatter Pujals 2009-12-18 21:22:58 +01:00
parent 1c4c3afb27
commit 44712c274e

View File

@ -556,10 +556,7 @@ LookingGlass.prototype = {
}));
this._entry.clutter_text.connect('key-press-event', Lang.bind(this, function(o, e) {
let symbol = e.get_key_symbol();
if (symbol == Clutter.Escape) {
this.close();
return true;
} else if (symbol == Clutter.Up) {
if (symbol == Clutter.Up) {
if (this._historyNavIndex >= this._history.length - 1)
return true;
this._historyNavIndex++;
@ -704,6 +701,16 @@ LookingGlass.prototype = {
this._resizeTo(actor);
},
// Handle key events which are relevant for all tabs of the LookingGlass
_globalKeyPressEvent : function(actor, event) {
let symbol = event.get_key_symbol();
if (symbol == Clutter.Escape) {
this.close();
return true;
}
return false;
},
open : function() {
if (this._open)
return;
@ -711,6 +718,9 @@ LookingGlass.prototype = {
if (!Main.pushModal(this.actor))
return;
this._keyPressEventId = global.stage.connect('key-press-event',
Lang.bind(this, this._globalKeyPressEvent));
this.actor.show();
this.actor.lower(Main.chrome.actor);
this._open = true;
@ -729,6 +739,9 @@ LookingGlass.prototype = {
if (!this._open)
return;
if (this._keyPressEventId)
global.stage.disconnect(this._keyPressEventId);
this._historyNavIndex = -1;
this._open = false;
Tweener.removeTweens(this.actor);