[gnome-tetravex] Handle Escape key.
- From: Arnaud B. <arnaudb src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-tetravex] Handle Escape key.
- Date: Sat, 21 Sep 2019 01:29:28 +0000 (UTC)
commit caf59b69456a3935466f0ea97bc5f1a9d8736791
Author: Arnaud Bonatti <arnaud bonatti gmail com>
Date: Sat Sep 21 03:21:24 2019 +0200
Handle Escape key.
src/gnome-tetravex.vala | 42 +++++++++++++++++++++++++++++-------------
1 file changed, 29 insertions(+), 13 deletions(-)
---
diff --git a/src/gnome-tetravex.vala b/src/gnome-tetravex.vala
index e9a45c2..34e21e5 100644
--- a/src/gnome-tetravex.vala
+++ b/src/gnome-tetravex.vala
@@ -601,7 +601,7 @@ private class Tetravex : Gtk.Application
view.redo ();
}
- private void pause_cb (SimpleAction action, Variant? parameter)
+ private void pause_cb (/* SimpleAction action, Variant? parameter */)
{
puzzle.paused = !puzzle.paused;
undo_action.set_enabled (puzzle.can_undo && !puzzle.is_solved && !puzzle.paused);
@@ -629,31 +629,47 @@ private class Tetravex : Gtk.Application
action.change_state (parameter);
}
- /*\
- * * help/about
- \*/
-
private bool on_key_press_event (Widget widget, Gdk.EventKey event)
{
string name = (!) (Gdk.keyval_name (event.keyval) ?? "");
- if (name == "F1") // TODO fix dance done with the F1 & <Primary>F1 shortcuts that show help overlay
+ if (name == "Escape" && !puzzle.is_solved)
{
- // TODO close popovers
- if ((event.state & Gdk.ModifierType.CONTROL_MASK) != 0)
- return false; // help overlay
- if ((event.state & Gdk.ModifierType.SHIFT_MASK) == 0)
+ if (puzzle.paused)
{
- help_cb ();
+ pause_cb ();
+ return true;
+ }
+ else if (view.tile_selected)
+ {
+ view.release_selected_tile ();
return true;
}
- about_cb ();
- return true;
}
+ else if (name == "F1")
+ return on_f1_pressed (event); // TODO fix dance done with the F1 & <Primary>F1 shortcuts that
show help overlay
return false;
}
+ /*\
+ * * help/about
+ \*/
+
+ private bool on_f1_pressed (Gdk.EventKey event)
+ {
+ // TODO close popovers
+ if ((event.state & Gdk.ModifierType.CONTROL_MASK) != 0)
+ return false; // help overlay
+ if ((event.state & Gdk.ModifierType.SHIFT_MASK) == 0)
+ {
+ help_cb ();
+ return true;
+ }
+ about_cb ();
+ return true;
+ }
+
private void help_cb ()
{
try
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]