mirror of
https://github.com/edu4rdshl/gnome-shell.git
synced 2026-07-17 23:24:51 +00:00
popupMenu: Handle key-press events on sourceActor
The behavior of opening/closing/navigating a menu from its source actor is generic enough to not limit it to PanelMenu.Buttons, so move the code into PopupMenu itself. https://bugzilla.gnome.org/show_bug.cgi?id=735614
This commit is contained in:
parent
9de05994db
commit
1d58ea25ab
2 changed files with 28 additions and 21 deletions
|
|
@ -101,7 +101,6 @@ const Button = new Lang.Class({
|
|||
accessible_role: Atk.Role.MENU });
|
||||
|
||||
this.actor.connect('event', Lang.bind(this, this._onEvent));
|
||||
this.actor.connect('key-press-event', Lang.bind(this, this._onSourceKeyPress));
|
||||
this.actor.connect('notify::visible', Lang.bind(this, this._onVisibilityChanged));
|
||||
|
||||
if (dontCreateMenu)
|
||||
|
|
@ -140,26 +139,6 @@ const Button = new Lang.Class({
|
|||
return Clutter.EVENT_PROPAGATE;
|
||||
},
|
||||
|
||||
_onSourceKeyPress: function(actor, event) {
|
||||
if (!this.menu)
|
||||
return Clutter.EVENT_PROPAGATE;
|
||||
|
||||
let symbol = event.get_key_symbol();
|
||||
if (symbol == Clutter.KEY_space || symbol == Clutter.KEY_Return) {
|
||||
this.menu.toggle();
|
||||
return Clutter.EVENT_STOP;
|
||||
} else if (symbol == Clutter.KEY_Escape && this.menu.isOpen) {
|
||||
this.menu.close();
|
||||
return Clutter.EVENT_STOP;
|
||||
} else if (symbol == Clutter.KEY_Down) {
|
||||
if (!this.menu.isOpen)
|
||||
this.menu.toggle();
|
||||
this.menu.actor.navigate_focus(this.actor, Gtk.DirectionType.DOWN, false);
|
||||
return Clutter.EVENT_STOP;
|
||||
} else
|
||||
return Clutter.EVENT_PROPAGATE;
|
||||
},
|
||||
|
||||
_onVisibilityChanged: function() {
|
||||
if (!this.menu)
|
||||
return;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue