From 6264e526efa924842ae73727f2121a3668e76b69 Mon Sep 17 00:00:00 2001 From: Stefan Dresselhaus Date: Mon, 20 Jan 2014 20:04:21 +0100 Subject: [PATCH] window now closes on escape & quit-button --- src/Main.hs | 27 +++++++++++++++++++++++++-- 1 file changed, 25 insertions(+), 2 deletions(-) diff --git a/src/Main.hs b/src/Main.hs index 7ab9af4..cfab8ea 100644 --- a/src/Main.hs +++ b/src/Main.hs @@ -223,7 +223,7 @@ run = do win <- asks envWindow -- draw Scene - --draw + draw liftIO $ do glSwapWindow win -- getEvents & process @@ -324,4 +324,27 @@ processEvents = do processEvent :: Event -> Pioneers () processEvent e = do - liftIO $ putStrLn (show e) \ No newline at end of file + case eventData e of + Window _ winEvent -> + case winEvent of + Closing -> modify $ \s -> s { + stateWinClose = True + } + _ -> return () + Keyboard movement _ repeat key -> --up/down window(ignored) true/false actualKey + -- need modifiers? use "keyModifiers key" to get them + case keyScancode key of + Escape -> modify $ \s -> s { + stateWinClose = True + } + _ -> return () + MouseMotion _ id st pos xrel yrel -> + return () + MouseButton _ id button state pos -> + return () + MouseWheel _ id hscroll vscroll -> + return () + Quit -> modify $ \s -> s {stateWinClose = True} + -- there is more (joystic, touchInterface, ...), but currently ignored + _ -> return () + liftIO $ putStrLn $ unwords ["Processing Event:",(show e)] \ No newline at end of file