[gnome-nibbles] Make 'Next Level' button the default widget
- From: Iulian Radu <iulianradu src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-nibbles] Make 'Next Level' button the default widget
- Date: Mon, 24 Oct 2016 14:05:00 +0000 (UTC)
commit 628ffde15c7f9e5c6013c6caeb4348536cda4e1d
Author: Iulian Radu <iulian radu67 gmail com>
Date: Mon Oct 24 16:58:59 2016 +0300
Make 'Next Level' button the default widget
Currently, when a level is completed, the focus is set on the Next
Level button so by pressing Enter the user can immediately start the
next level. This can sometimes lead to problems if the focus is changed.
Instead of relying on the widget's focus, make the 'Next Level' button
the default widget so by pressing enter with no focus, the next level
is always started.
https://bugzilla.gnome.org/show_bug.cgi?id=773049
data/nibbles.ui | 1 +
src/gnome-nibbles.vala | 4 +++-
2 files changed, 4 insertions(+), 1 deletions(-)
---
diff --git a/data/nibbles.ui b/data/nibbles.ui
index 646e326..99fecd0 100644
--- a/data/nibbles.ui
+++ b/data/nibbles.ui
@@ -32,6 +32,7 @@
<child>
<object class="GtkOverlay" id="main_overlay">
<property name="visible">True</property>
+ <property name="can-default">True</property>
<child>
<object class="GtkBox" id="vbox">
<property name="visible">True</property>
diff --git a/src/gnome-nibbles.vala b/src/gnome-nibbles.vala
index 84bc636..60f7663 100644
--- a/src/gnome-nibbles.vala
+++ b/src/gnome-nibbles.vala
@@ -893,6 +893,7 @@ public class Nibbles : Gtk.Application
button.valign = Gtk.Align.END;
button.set_margin_bottom (100);
button.get_style_context ().add_class ("suggested-action");
+ button.set_can_default (true);
button.clicked.connect (() => {
label.destroy ();
button.destroy ();
@@ -906,10 +907,11 @@ public class Nibbles : Gtk.Application
overlay.add_overlay (button);
overlay.show ();
+ overlay.grab_default ();
Timeout.add (500, () => {
button.show ();
- button.grab_focus ();
+ button.grab_default ();
return Source.REMOVE;
});
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]