Add gesture event for swipe down - crossword.koplugin - Unnamed repository; edit this file 'description' to name the repository. (DIR) Log (DIR) Files (DIR) Refs (DIR) Submodules (DIR) README (DIR) LICENSE --- (DIR) commit 6ad04568ee22df0580d98b2a5b6fd4e7e2fb6f06 (DIR) parent 4a6e9447b35f096c688fbbbc0420cef8ccae2d46 (HTM) Author: Scarlett <social@scarlettmcallister.com> Date: Sun, 23 Jan 2022 17:26:35 -0400 Add gesture event for swipe down Diffstat: M gameview.lua | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+), 0 deletions(-) --- (DIR) diff --git a/gameview.lua b/gameview.lua @@ -1,3 +1,4 @@ +local BD = require("ui/bidi") local Blitbuffer = require("ffi/blitbuffer") local CenterContainer = require("ui/widget/container/centercontainer") local Device = require("device") @@ -31,12 +32,24 @@ function GameView:init() } -- Initialize the grid. self.puzzle:getGrid() + -- Load the state of the puzzle + --- @todo: This should be implemented differently... see puzzle:init FMI + self.puzzle:load() -- Set the active clue to first grid element. self.active_row_num = 1 self.active_col_num = 1 self.active_clue = self.puzzle:getClueByPos(1,1, self.active_direction) or "" -- Set the initial active direction self.puzzle:setActiveDirection(Solve.DOWN) + -- Initialize gesture events. + if Device:isTouchDevice() then + self.ges_events.Swipe = { + GestureRange:new{ + ges = "swipe", + range = self.dimen, + } + } + end end function GameView:render() @@ -221,4 +234,14 @@ function GameView:toggleDirection() self:refreshGameView() end +function GameView:onSwipe(arg, ges_ev) + local direction = BD.flipDirectionIfMirroredUILayout(ges_ev.direction) + if direction == "south" then + --- @todo: On south-bound swipe show a menu. The menu will have options for: + --- 1) exiting the game. + --- 2) checking a square. + --- 3) ... + end +end + return GameView