[four-in-a-row/arnaudb/wip/gtk4: 80/92] Get keyboard inputs.




commit d3854694047604a9bc05aef9ae1277334646ee97
Author: Arnaud Bonatti <arnaud bonatti gmail com>
Date:   Mon Apr 27 19:30:08 2020 +0200

    Get keyboard inputs.

 src/game-board-view.vala | 19 +++++++++++++++++++
 1 file changed, 19 insertions(+)
---
diff --git a/src/game-board-view.vala b/src/game-board-view.vala
index 1e791ab..1a38e05 100644
--- a/src/game-board-view.vala
+++ b/src/game-board-view.vala
@@ -46,6 +46,25 @@ private class GameBoardView : Gtk.DrawingArea
         size_allocate.connect (on_size_allocate);
     }
 
+    protected override bool focus (Gtk.DirectionType direction)
+    {
+        if (!is_focus ())
+        {
+            grab_focus ();
+            return true;
+        }
+        return false;
+    }
+
+    protected override bool grab_focus ()
+    {
+        Gtk.Root? root = get_root ();
+        if (root == null)
+            assert_not_reached ();
+        ((!) root).set_focus (this);
+        return true;
+    }
+
     /*\
     * * drawing variables
     \*/


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]