keyboard: Fill suggestion on button-press-event

Like OSK key buttons, we must avoid the default grabbing behavior
of StButton here. Hook to button-press-event to commit the selected
words, so we get a chance to prevent focus changes on the current
key focus.

Likewise, connect to ::touch-event to handle touch input.

Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/2278>
This commit is contained in:
Carlos Garnacho 2022-04-22 16:19:14 +02:00 committed by Florian Müllner
parent b210b2de72
commit aa341104e5

View File

@ -175,7 +175,17 @@ class Suggestions extends St.BoxLayout {
add(word, callback) {
let button = new St.Button({ label: word });
button.connect('clicked', callback);
button.connect('button-press-event', () => {
callback();
return Clutter.EVENT_STOP;
});
button.connect('touch-event', (actor, event) => {
if (event.type() !== Clutter.EventType.TOUCH_BEGIN)
return Clutter.EVENT_PROPAGATE;
callback();
return Clutter.EVENT_STOP;
});
this.add_child(button);
}