viewSelector: Allow to start navigating results using arrow keys

We currently require users to tab away from the search entry before
search results can be navigated using arrow keys. For convenience,
support using arrow keys directly from the entry.

https://bugzilla.gnome.org/show_bug.cgi?id=663901
This commit is contained in:
Florian Müllner
2012-03-10 03:40:46 +01:00
parent 700f706428
commit 384c7e2c17
2 changed files with 28 additions and 4 deletions

View File

@ -266,6 +266,7 @@ const SearchResults = new Lang.Class({
button.activate = Lang.bind(this, function() {
this._openSearchSystem.activateResult(provider.id);
});
button.actor = button;
this._searchProvidersBox.add(button);
},
@ -450,13 +451,21 @@ const SearchResults = new Lang.Class({
},
navigateFocus: function(direction) {
if (direction == Gtk.DirectionType.TAB_FORWARD && this._defaultResult) {
let rtl = this.actor.get_text_direction() == Clutter.TextDirection.RTL;
if (direction == Gtk.DirectionType.TAB_BACKWARD ||
direction == (rtl ? Gtk.DirectionType.RIGHT
: Gtk.DirectionType.LEFT) ||
direction == Gtk.DirectionType.UP) {
this.actor.navigate_focus(null, direction, false);
return;
}
let from = this._defaultResult ? this._defaultResult.actor : null;
this.actor.navigate_focus(from, direction, false);
if (this._defaultResult) {
// The default result appears focused, so navigate directly to the
// next result.
this.actor.navigate_focus(null, direction, false);
this.actor.navigate_focus(global.stage.key_focus, direction, false);
} else {
this.actor.navigate_focus(null, direction, false);
}
}
});