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:
parent
1c4c3afb27
commit
44712c274e
@ -556,10 +556,7 @@ LookingGlass.prototype = {
|
|||||||
}));
|
}));
|
||||||
this._entry.clutter_text.connect('key-press-event', Lang.bind(this, function(o, e) {
|
this._entry.clutter_text.connect('key-press-event', Lang.bind(this, function(o, e) {
|
||||||
let symbol = e.get_key_symbol();
|
let symbol = e.get_key_symbol();
|
||||||
if (symbol == Clutter.Escape) {
|
if (symbol == Clutter.Up) {
|
||||||
this.close();
|
|
||||||
return true;
|
|
||||||
} else if (symbol == Clutter.Up) {
|
|
||||||
if (this._historyNavIndex >= this._history.length - 1)
|
if (this._historyNavIndex >= this._history.length - 1)
|
||||||
return true;
|
return true;
|
||||||
this._historyNavIndex++;
|
this._historyNavIndex++;
|
||||||
@ -704,6 +701,16 @@ LookingGlass.prototype = {
|
|||||||
this._resizeTo(actor);
|
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() {
|
open : function() {
|
||||||
if (this._open)
|
if (this._open)
|
||||||
return;
|
return;
|
||||||
@ -711,6 +718,9 @@ LookingGlass.prototype = {
|
|||||||
if (!Main.pushModal(this.actor))
|
if (!Main.pushModal(this.actor))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
this._keyPressEventId = global.stage.connect('key-press-event',
|
||||||
|
Lang.bind(this, this._globalKeyPressEvent));
|
||||||
|
|
||||||
this.actor.show();
|
this.actor.show();
|
||||||
this.actor.lower(Main.chrome.actor);
|
this.actor.lower(Main.chrome.actor);
|
||||||
this._open = true;
|
this._open = true;
|
||||||
@ -729,6 +739,9 @@ LookingGlass.prototype = {
|
|||||||
if (!this._open)
|
if (!this._open)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
if (this._keyPressEventId)
|
||||||
|
global.stage.disconnect(this._keyPressEventId);
|
||||||
|
|
||||||
this._historyNavIndex = -1;
|
this._historyNavIndex = -1;
|
||||||
this._open = false;
|
this._open = false;
|
||||||
Tweener.removeTweens(this.actor);
|
Tweener.removeTweens(this.actor);
|
||||||
|
Loading…
Reference in New Issue
Block a user