popupMenu: Use an appropriate key to move focus into the menu
The code from PanelMenu.Button assumed menus would open below their source actor, making KEY_Down a good choice; however with the new generic code, we should base the key used on the actual menu position. https://bugzilla.gnome.org/show_bug.cgi?id=735614
This commit is contained in:
parent
1d58ea25ab
commit
98847f2279
@ -746,6 +746,22 @@ const PopupMenu = new Lang.Class({
|
|||||||
},
|
},
|
||||||
|
|
||||||
_onKeyPress: function(actor, event) {
|
_onKeyPress: function(actor, event) {
|
||||||
|
let navKey;
|
||||||
|
switch (this._boxPointer.arrowSide) {
|
||||||
|
case St.Side.TOP:
|
||||||
|
navKey = Clutter.KEY_Down;
|
||||||
|
break;
|
||||||
|
case St.Side.BOTTOM:
|
||||||
|
navKey = Clutter.KEY_Up;
|
||||||
|
break;
|
||||||
|
case St.Side.LEFT:
|
||||||
|
navKey = Clutter.KEY_Right;
|
||||||
|
break;
|
||||||
|
case St.Side.RIGHT:
|
||||||
|
navKey = Clutter.KEY_Left;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
let symbol = event.get_key_symbol();
|
let symbol = event.get_key_symbol();
|
||||||
if (symbol == Clutter.KEY_space || symbol == Clutter.KEY_Return) {
|
if (symbol == Clutter.KEY_space || symbol == Clutter.KEY_Return) {
|
||||||
this.toggle();
|
this.toggle();
|
||||||
@ -753,10 +769,10 @@ const PopupMenu = new Lang.Class({
|
|||||||
} else if (symbol == Clutter.KEY_Escape && this.isOpen) {
|
} else if (symbol == Clutter.KEY_Escape && this.isOpen) {
|
||||||
this.close();
|
this.close();
|
||||||
return Clutter.EVENT_STOP;
|
return Clutter.EVENT_STOP;
|
||||||
} else if (symbol == Clutter.KEY_Down) {
|
} else if (symbol == navKey) {
|
||||||
if (!this.isOpen)
|
if (!this.isOpen)
|
||||||
this.toggle();
|
this.toggle();
|
||||||
this.actor.navigate_focus(actor, Gtk.DirectionType.DOWN, false);
|
this.actor.navigate_focus(null, Gtk.DirectionType.TAB_FORWARD, false);
|
||||||
return Clutter.EVENT_STOP;
|
return Clutter.EVENT_STOP;
|
||||||
} else
|
} else
|
||||||
return Clutter.EVENT_PROPAGATE;
|
return Clutter.EVENT_PROPAGATE;
|
||||||
|
Loading…
Reference in New Issue
Block a user